test/tools/javac/lambda/TargetType21.java

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

author
vromero
date
Mon, 02 Sep 2013 22:38:36 +0100
changeset 2000
4a6acc42c3a1
parent 1510
7873d37f5b37
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 8003280
     4  * @summary Add lambda tests
     5  *  check that candidates with cyclic type-inference are removed from the
     6  *          set of applicable methods
     7  * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java
     8  */
    10 class TargetType21 {
    11     interface SAM1 {
    12         String m1(Integer n) throws Exception;
    13     }
    15     interface SAM2 {
    16         void m2(Integer n);
    17     }
    19     interface SAM3<R,A> {
    20         R m3(A n);
    21     }
    23     void call(SAM1 sam) { }
    24     void call(SAM2 sam) { }
    25     <R,A> void call(SAM3<R,A> sam) { }
    27     void test() {
    28         call(x -> { throw new Exception(); }); //ambiguous
    29         call((Integer x) -> { System.out.println(""); }); //ok (only one is void)
    30         call((Integer x) -> { return (Object) null; }); //ok (only one returns Object)
    31         call(x -> { System.out.println(""); }); //ambiguous
    32         call(x -> { return (Object) null; }); //ambiguous
    33         call(x -> { return null; }); //ambiguous
    34     }
    35 }

mercurial