1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/TargetType60.java Fri Feb 15 16:29:58 2013 +0000 1.3 @@ -0,0 +1,51 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8007462 1.7 + * @summary Fix provisional applicability for method references 1.8 + * @compile/fail/ref=TargetType60.out -XDrawDiagnostics TargetType60.java 1.9 + */ 1.10 +class TargetType60 { 1.11 + 1.12 + interface Sam0 { 1.13 + void m(); 1.14 + } 1.15 + 1.16 + interface Sam1<X> { 1.17 + void m(X x); 1.18 + } 1.19 + 1.20 + interface Sam2<X,Y> { 1.21 + void m(X x, Y y); 1.22 + } 1.23 + 1.24 + void m0() { } 1.25 + void m1(String s) { } 1.26 + void m2(String s1, String s2) { } 1.27 + 1.28 + void m01() { } 1.29 + void m01(String s) { } 1.30 + 1.31 + void m012() { } 1.32 + void m012(String s) { } 1.33 + void m012(String s1, String s2) { } 1.34 + 1.35 + static String g(Sam0 s) { return null; } 1.36 + static <U> U g(Sam1<U> s) { return null; } 1.37 + static <U> U g(Sam2<U,String> s) { return null; } 1.38 + 1.39 + void testBound() { 1.40 + String s1 = g(this::m0); //ok - resolves to g(Sam0) 1.41 + String s2 = g(this::m1); //ok - resolves to g(Sam1) 1.42 + String s3 = g(this::m2); //ok - resolves to g(Sam2) 1.43 + String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply) 1.44 + String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply) 1.45 + } 1.46 + 1.47 + static void testUnbound() { 1.48 + TargetType60 s1 = g(TargetType60::m0); //ok - resolves to g(Sam1) 1.49 + TargetType60 s2 = g(TargetType60::m1); //ok - resolves to g(Sam2) 1.50 + TargetType60 s3 = g(TargetType60::m2); //none is applicable 1.51 + TargetType60 s4 = g(TargetType60::m01);//ambiguous (g(Sam1), g(Sam2) apply) 1.52 + TargetType60 s5 = g(TargetType60::m012);//ambiguous (g(Sam1), g(Sam2) apply) 1.53 + } 1.54 +}