1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/BadTargetType.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,23 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8003280 1.7 + * @summary Add lambda tests 1.8 + * check that only SAM are allowed as target types for lambda expressions 1.9 + * @author Jan Lahoda 1.10 + * @author Maurizio Cimadamore 1.11 + * @compile/fail/ref=BadTargetType.out -XDrawDiagnostics BadTargetType.java 1.12 + */ 1.13 + 1.14 +class BadTargetType { 1.15 + 1.16 + static void m1(Object o) {} 1.17 + void m2(Object o) {} 1.18 + 1.19 + static Object l1 = (int pos)-> { }; 1.20 + Object l2 = (int pos)-> { }; 1.21 + 1.22 + { 1.23 + m1((int pos)-> { }); 1.24 + m2((int pos)-> { }); 1.25 + } 1.26 +}