8042759: Lambda returning implicitly-typed lambdas considered pertinent to applicability

Thu, 19 Jun 2014 23:52:33 +0100

author
vromero
date
Thu, 19 Jun 2014 23:52:33 +0100
changeset 2429
94ea21ecfe2d
parent 2428
ce1d9dd2e9eb
child 2430
f4381f9541e6

8042759: Lambda returning implicitly-typed lambdas considered pertinent to applicability
Reviewed-by: mcimadamore

src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java file | annotate | diff | comparison | revisions
test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java file | annotate | diff | comparison | revisions
test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Jun 19 15:39:37 2014 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Jun 19 23:52:33 2014 +0100
     1.3 @@ -930,7 +930,7 @@
     1.4  
     1.5          LambdaReturnScanner() {
     1.6              super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
     1.7 -                    FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
     1.8 +                    FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
     1.9          }
    1.10      }
    1.11  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java	Thu Jun 19 23:52:33 2014 +0100
     2.3 @@ -0,0 +1,33 @@
     2.4 +/*
     2.5 + * @test /nodynamiccopyright/
     2.6 + * @bug 8042759
     2.7 + * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability
     2.8 + * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java
     2.9 + */
    2.10 +
    2.11 +abstract class ImplicitLambdaConsideredForApplicabilityTest {
    2.12 +    interface A {
    2.13 +        B m(int a, int b);
    2.14 +    }
    2.15 +
    2.16 +    interface C {
    2.17 +        String m(int a, int b);
    2.18 +    }
    2.19 +
    2.20 +    interface B {
    2.21 +        int m(int c);
    2.22 +    }
    2.23 +
    2.24 +    abstract void foo(A a);
    2.25 +
    2.26 +    abstract void foo(C c);
    2.27 +
    2.28 +    void bar() {
    2.29 +        foo((int a, int b) -> {
    2.30 +            if(a < b)
    2.31 +                return c -> 0;
    2.32 +            else
    2.33 +                return c -> 0;
    2.34 +        });
    2.35 +    }
    2.36 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out	Thu Jun 19 23:52:33 2014 +0100
     3.3 @@ -0,0 +1,2 @@
     3.4 +ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest
     3.5 +1 error

mercurial