test/tools/javac/lambda/TargetType66.java

Mon, 02 Sep 2013 22:38:36 +0100

author
vromero
date
Mon, 02 Sep 2013 22:38:36 +0100
changeset 2000
4a6acc42c3a1
parent 1677
94a202228ec2
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8016177: structural most specific and stuckness
Reviewed-by: jjg, vromero
Contributed-by: maurizio.cimadamore@oracle.com

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8009131
     4  * @summary Overload: javac should discard methods that lead to errors in lambdas with implicit parameter types
     5  * @compile/fail/ref=TargetType66.out -XDrawDiagnostics TargetType66.java
     6  */
     7 class TargetType66 {
     8     interface SAM1 {
     9         void m(String s);
    10     }
    12     interface SAM2 {
    13         void m(Integer s);
    14     }
    16     void g(SAM1 s1) { }
    17     void g(SAM2 s2) { }
    19     void test() {
    20         g(x->{ String s = x; }); //ambiguous
    21         g(x->{ Integer i = x; }); //ambiguous
    22         g(x->{ Object o = x; }); //ambiguous
    23         g(x->{ Character c = x; }); //error: inapplicable methods
    24         g(x->{ Character c = ""; }); //error: incompatible types
    25     }
    26 }

mercurial