TargetType60.java revision 1580:4ff468de829d
1/* 2 * @test /nodynamiccopyright/ 3 * @bug 8007462 4 * @summary Fix provisional applicability for method references 5 * @compile/fail/ref=TargetType60.out -XDrawDiagnostics TargetType60.java 6 */ 7class TargetType60 { 8 9 interface Sam0 { 10 void m(); 11 } 12 13 interface Sam1<X> { 14 void m(X x); 15 } 16 17 interface Sam2<X,Y> { 18 void m(X x, Y y); 19 } 20 21 void m0() { } 22 void m1(String s) { } 23 void m2(String s1, String s2) { } 24 25 void m01() { } 26 void m01(String s) { } 27 28 void m012() { } 29 void m012(String s) { } 30 void m012(String s1, String s2) { } 31 32 static String g(Sam0 s) { return null; } 33 static <U> U g(Sam1<U> s) { return null; } 34 static <U> U g(Sam2<U,String> s) { return null; } 35 36 void testBound() { 37 String s1 = g(this::m0); //ok - resolves to g(Sam0) 38 String s2 = g(this::m1); //ok - resolves to g(Sam1) 39 String s3 = g(this::m2); //ok - resolves to g(Sam2) 40 String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply) 41 String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply) 42 } 43 44 static void testUnbound() { 45 TargetType60 s1 = g(TargetType60::m0); //ok - resolves to g(Sam1) 46 TargetType60 s2 = g(TargetType60::m1); //ok - resolves to g(Sam2) 47 TargetType60 s3 = g(TargetType60::m2); //none is applicable 48 TargetType60 s4 = g(TargetType60::m01);//ambiguous (g(Sam1), g(Sam2) apply) 49 TargetType60 s5 = g(TargetType60::m012);//ambiguous (g(Sam1), g(Sam2) apply) 50 } 51} 52