This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250554 - Implicitly-typed lambda parameters don't work correctly in target pattern
Summary: Implicitly-typed lambda parameters don't work correctly in target pattern
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-19 17:55 UTC by Jan Lahoda
Modified: 2016-07-07 07:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Lahoda 2015-02-19 17:55:05 UTC
Consider this rule/script:
---
$foo = $map.get($key);
if ($foo == null) {
    $foo = $expr$;
    $map.put($key, $foo);
} :: $map instanceof java.util.Map
=>
$foo = $map.computeIfAbsent($key, p -> $expr$);
;;
---

And this sample file:
---
        Map<String, String> map = new HashMap<>();
        String foo;
        String key = "";
        foo = map.get(key);
        if (foo == null) {
            foo = "";
            map.put(key, foo);
        }
---

Applying the transformation leads to:
        foo = map.computeIfAbsent(key, (<any> p) -> (""));
which is not ideal.

This is on:

Product Version: NetBeans IDE 8.0 (Build 20140315-f817edfd05cd)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Linux version 3.16.0-30-generic running on amd64; UTF-8; en_US (nb)
User directory: /usr/local/home/lahvac/.netbeans/dev
Cache directory: /usr/local/home/lahvac/.netbeans/dev/var/cache
Comment 1 Martin Balin 2016-07-07 07:16:00 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss