diff -r 000000000000 -r 959103a6100f test/tools/javac/lambda/TargetType23.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/TargetType23.java Wed Apr 27 01:34:52 2016 +0800 @@ -0,0 +1,42 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check case of ambiguous method call with lambda whose body cannot + complete normally + * @compile/fail/ref=TargetType23.out -XDrawDiagnostics TargetType23.java + */ + +class TargetType23 { + + interface Sam0 { + void m(); + } + + interface Sam1 { + int m(); + } + + interface Sam2 { + String m(); + } + + interface Sam3 { + A m(); + } + + + void call(Sam0 s) { } + void call(Sam1 s) { } + void call(Sam2 s) { } + void call(Sam3 s) { } + + void call2(Sam0 s) { } + void call2(Sam2 s) { } + void call2(Sam3 s) { } + + void test() { + call(()-> { throw new RuntimeException(); }); // ambiguous - call(Sam1) vs. call(Sam2) + call2(()-> { throw new RuntimeException(); }); // ok + } +}