test/tools/javac/lambda/MostSpecific12.java

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 0
959103a6100f
permissions
-rw-r--r--

merge

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8034223
     4  * @summary Most-specific testing with inference variables in function parameter types
     5  * @compile/fail/ref=MostSpecific12.out -XDrawDiagnostics MostSpecific12.java
     6  */
     7 class MostSpecific12 {
     9     interface I<T> { void take(T arg1, String arg2); }
    10     interface J<T> { void take(String arg1, T arg2); }
    11     interface K { void take(String arg1, String arg2); }
    13     <T> void m1(I<T> arg) {}
    14     void m1(K arg) {}
    16     <T> void m2(J<T> arg) {}
    17     <T> void m2(K arg) {}
    19     <T> void m3(I<T> arg) {}
    20     <T> void m3(J<T> arg) {}
    22     void test() {
    23         m1((String s1, String s2) -> {}); // ok
    24         m2((String s1, String s2) -> {}); // ok
    25         m3((String s1, String s2) -> {}); // error
    27         m1(this::referencedMethod); // ok
    28         m2(this::referencedMethod); // ok
    29         m3(this::referencedMethod); // error
    31         m1(String::compareTo); // ok
    32         m2(String::compareTo); // ok
    33         m3(String::compareTo); // error
    34     }
    36     void referencedMethod(String s1, String s2) {}
    38 }

mercurial