TargetType60.java revision 1609:08782b8b03ce
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 void n0() { } 33 void n1(String s) { } 34 void n2(TargetType60 rec, String s2) { } 35 36 void n01() { } 37 void n01(String s) { } 38 39 void n012() { } 40 void n012(String s) { } 41 void n012(TargetType60 rec, String s2) { } 42 43 static String g(Sam0 s) { return null; } 44 static <U> U g(Sam1<U> s) { return null; } 45 static <U> U g(Sam2<U,String> s) { return null; } 46 47 static <U> U u(Sam1<U> s) { return null; } 48 static <U> U u(Sam2<U,String> s) { return null; } 49 50 void testBound() { 51 String s1 = g(this::m0); //ok - resolves to g(Sam0) 52 String s2 = g(this::m1); //ok - resolves to g(Sam1) 53 String s3 = g(this::m2); //ok - resolves to g(Sam2) 54 String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply) 55 String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply) 56 } 57 58 static void testUnbound() { 59 TargetType60 s1 = u(TargetType60::n0); //ok - resolves to u(Sam1) 60 TargetType60 s2 = u(TargetType60::n1); //ambiguous (u(Sam1), u(Sam2) apply) 61 TargetType60 s3 = u(TargetType60::n2); //none is applicable 62 TargetType60 s4 = u(TargetType60::n01);//ambiguous (u(Sam1), u(Sam2) apply) 63 TargetType60 s5 = u(TargetType60::n012);//ambiguous (u(Sam1), u(Sam2) apply) 64 } 65} 66