1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/TargetType21.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,35 @@ 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(); }); //ambiguous 1.32 + call((Integer x) -> { System.out.println(""); }); //ok (only one is void) 1.33 + call((Integer x) -> { return (Object) null; }); //ok (only one returns Object) 1.34 + call(x -> { System.out.println(""); }); //ambiguous 1.35 + call(x -> { return (Object) null; }); //ambiguous 1.36 + call(x -> { return null; }); //ambiguous 1.37 + } 1.38 +}