1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/TargetType22.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,44 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8003280 1.7 + * @summary Add lambda tests 1.8 + * check that candidates with incompatible SAM descriptor args length 1.9 + are removed from the set of applicable methods 1.10 + * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java 1.11 + */ 1.12 + 1.13 +class TargetType22 { 1.14 + 1.15 + interface Sam0 { 1.16 + void m(); 1.17 + } 1.18 + 1.19 + interface Sam1<A> { 1.20 + void m(A a); 1.21 + } 1.22 + 1.23 + interface Sam2<A> { 1.24 + void m(A a1, A a2); 1.25 + } 1.26 + 1.27 + interface Sam3<A> { 1.28 + void m(A a1, A a2, A a3); 1.29 + } 1.30 + 1.31 + interface SamX<A> { 1.32 + void m(A... as); 1.33 + } 1.34 + 1.35 + void call(Sam0 s) { } 1.36 + void call(Sam1<String> s) { } 1.37 + void call(Sam2<String> s) { } 1.38 + void call(Sam3<String> s) { } 1.39 + void call(SamX<String> s) { } 1.40 + 1.41 + void test() { 1.42 + call(() -> { }); 1.43 + call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match 1.44 + call((a1, a2) -> { }); 1.45 + call((a1, a2, a3) -> { }); 1.46 + } 1.47 +}