diff -r 000000000000 -r 959103a6100f test/tools/javac/lambda/BadTargetType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/BadTargetType.java Wed Apr 27 01:34:52 2016 +0800 @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that only SAM are allowed as target types for lambda expressions + * @author Jan Lahoda + * @author Maurizio Cimadamore + * @compile/fail/ref=BadTargetType.out -XDrawDiagnostics BadTargetType.java + */ + +class BadTargetType { + + static void m1(Object o) {} + void m2(Object o) {} + + static Object l1 = (int pos)-> { }; + Object l2 = (int pos)-> { }; + + { + m1((int pos)-> { }); + m2((int pos)-> { }); + } +}