test/tools/javac/lambda/MostSpecific12.java

Wed, 14 May 2014 15:41:28 -0600

author
dlsmith
date
Wed, 14 May 2014 15:41:28 -0600
changeset 2395
9c577131ffa6
parent 0
959103a6100f
permissions
-rw-r--r--

8034223: Most-specific should not have any special treatment for boxed vs. unboxed types
Summary: Rewrite most-specific logic to conform to JLS 8 15.12.2.5
Reviewed-by: vromero

     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