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 270849 - NB shows false error for lambda passed in argument.
Summary: NB shows false error for lambda passed in argument.
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: Dev
Hardware: PC Other
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-10 18:39 UTC by attila.kelemen
Modified: 2017-06-28 01:49 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 attila.kelemen 2017-06-10 18:39:25 UTC
The following code is flagged with an error by NetBeans despite that it compiles fine. The classes pasted must be in separate files, otherwise the bug will not manifest itself:

    public class MyTestContainer {
        public void setEntry(MyTestEntryFactory entryFactory) {
        }
    }

    public interface MyTestEntry {
        public <DataType> void doSomething();
    }

    public interface MyTestEntryFactory {
        public MyTestEntry create();
    }

    public class MyTest {
        public static void test() {
            MyTestContainer container = new MyTestContainer();
            container.setEntry(() -> {
                return new MyTestEntry() {
                    @Override
                    public <DataType> void doSomething() {
                    }
                };
            });
        }
    }

The line containing "container.setEntry" is flagged as an error with the message: "The type of setEntry(MyTestEntryFactory) is erroneous".

Workaround: Casting the lambda explicitly to MyTestEntryFactory solves the issue.

Another issue in this code (though it might be unrelated) that the anonymous class implementing MyTestEntry is flagged to be convertible to lambda which is not true because doSomething() has a generic argument.
Comment 2 Quality Engineering 2017-06-28 01:49:10 UTC
Integrated into 'main-silver', will be available in build *201706280001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/21a01aaf51f7
User: Dusan Balek <dbalek@netbeans.org>
Log: Issues #269459 and #270849 fixed.