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 241034 - JDK8 lambda with return statement incorrectly gets hinted as enclosing methods return statement
Summary: JDK8 lambda with return statement incorrectly gets hinted as enclosing method...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-28 05:07 UTC by brettryan
Modified: 2014-01-31 02:40 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 brettryan 2014-01-28 05:07:16 UTC
Consider the following:

    public int foo() {
        final int r = 123;
        BooleanSupplier x = () -> {
            return true;
        };
        return r;
    }

This method while useless illustrates that netbeans will provide the hint for `r' that "The assigned value is never used". This is due to the return statement in the lambda expression.

Note that even though the return types are different there is no actual error produced, just the invalid warning.

A non block form will not produce this incorrect hint as it does not contain the return statement explicitly:

    public int foo() {
        final int r = 123;
        BooleanSupplier x = () -> true;
        return r;
    }
Comment 1 Svata Dedic 2014-01-28 17:15:43 UTC
Should be fixed in jet-main#9bc57d4748dd
Comment 2 Quality Engineering 2014-01-31 02:40:54 UTC
Integrated into 'main-silver', will be available in build *201401310001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/9bc57d4748dd
User: Svata Dedic <sdedic@netbeans.org>
Log: #241034: isolated lambda bodies the same way as methods, test added