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

Summary: Implicitly-typed lambda parameters don't work correctly in target pattern
Product: java Reporter: Jan Lahoda <jlahoda>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

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