diff -r 000000000000 -r 959103a6100f test/tools/javac/lambda/TargetType22.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/TargetType22.java Wed Apr 27 01:34:52 2016 +0800 @@ -0,0 +1,44 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that candidates with incompatible SAM descriptor args length + are removed from the set of applicable methods + * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java + */ + +class TargetType22 { + + interface Sam0 { + void m(); + } + + interface Sam1 { + void m(A a); + } + + interface Sam2 { + void m(A a1, A a2); + } + + interface Sam3 { + void m(A a1, A a2, A a3); + } + + interface SamX { + void m(A... as); + } + + void call(Sam0 s) { } + void call(Sam1 s) { } + void call(Sam2 s) { } + void call(Sam3 s) { } + void call(SamX s) { } + + void test() { + call(() -> { }); + call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match + call((a1, a2) -> { }); + call((a1, a2, a3) -> { }); + } +}