1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/TargetType21.java Sat Nov 17 19:01:03 2012 +0000 1.3 @@ -0,0 +1,33 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8003280 1.7 + * @summary Add lambda tests 1.8 + * check that candidates with cyclic type-inference are removed from the 1.9 + * set of applicable methods 1.10 + * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java 1.11 + */ 1.12 + 1.13 +class TargetType21 { 1.14 + interface SAM1 { 1.15 + String m1(Integer n) throws Exception; 1.16 + } 1.17 + 1.18 + interface SAM2 { 1.19 + void m2(Integer n); 1.20 + } 1.21 + 1.22 + interface SAM3<R,A> { 1.23 + R m3(A n); 1.24 + } 1.25 + 1.26 + void call(SAM1 sam) { } 1.27 + void call(SAM2 sam) { } 1.28 + <R,A> void call(SAM3<R,A> sam) { } 1.29 + 1.30 + void test() { 1.31 + call(x -> { throw new Exception(); }); //ok - resolves to call(SAM1) 1.32 + call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2) 1.33 + call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference 1.34 + call(x -> { return null; }); ////ok - resolves to call(SAM1) 1.35 + } 1.36 +}