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 255734 - Hint - Use Anonymous inner class - not converting the lambda expression to inner class correctly
Summary: Hint - Use Anonymous inner class - not converting the lambda expression to in...
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: 2015-10-06 13:03 UTC by seeni
Modified: 2016-07-14 01:51 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 seeni 2015-10-06 13:03:12 UTC
import java.util.Objects;
import java.util.function.Function;

@FunctionalInterface
interface TriFunction<A, B, C, R> {

    public R apply(A a, B b, C c);

    default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after) {
        Objects.requireNonNull(after);
        return (A a, B b, C c) -> after.apply(apply(a, b, c));
    }
}


when netbeans converts the below lambda

return (A a, B b, C c) -> after.apply(apply(a, b, c));

produces the below anonymous inner class

return new TriFunction<A, B, C, V>() {

            public V apply(A a, B b, C c) {
                return after.apply(apply(a, b, c));
            }
        };

It should actually convert to 

return new TriFunction<A, B, C, V>() {

            public V apply(A a, B b, C c) {
                return after.apply(TriFunction.this.apply(a, b, c));
            }
        };

Intellij IDE converts this properly.
Comment 1 Jiri Prox 2015-10-06 14:04:16 UTC
reproducible
Comment 2 Svata Dedic 2016-06-21 11:10:26 UTC
Should be fixed by jet-main#0ce9efcb9378; I implemented compensations for shadowed methods, fields, enum values and types.
Comment 3 Quality Engineering 2016-07-14 01:51:22 UTC
Integrated into 'main-silver', will be available in build *201607140002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0ce9efcb9378
User: Svata Dedic <sdedic@netbeans.org>
Log: #255734: use qualifier if an identifier would be shadowed by the introduced class or something inherited