1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/BadLambdaPos.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,31 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8003280 1.7 + * @summary Add lambda tests 1.8 + * check that lambda is only allowed in argument/cast/assignment context 1.9 + * @author Maurizio Cimadamore 1.10 + * @compile/fail/ref=BadLambdaPos.out -XDrawDiagnostics BadLambdaPos.java 1.11 + */ 1.12 + 1.13 +interface SAM { 1.14 + void m(Integer x); 1.15 +} 1.16 + 1.17 +class Test { 1.18 + void test(Object x) {} 1.19 + 1.20 + void test1() { 1.21 + test((int x)-> { } + (int x)-> { } ); 1.22 + test((int x)-> { } instanceof Object ); 1.23 + } 1.24 + 1.25 + void test2() { 1.26 + int i2 = (int x)-> { } + (int x)-> { }; 1.27 + boolean b = (int x)-> { } instanceof Object; 1.28 + } 1.29 + 1.30 + void test3() { 1.31 + test((Object)(int x)-> { }); 1.32 + Object o = (Object)(int x)-> { }; 1.33 + } 1.34 +}