14547
|
1 |
/*
|
|
2 |
* @test /nodynamiccopyright/
|
|
3 |
* @bug 8003280
|
|
4 |
* @summary Add lambda tests
|
|
5 |
* check that candidates with cyclic type-inference are removed from the
|
|
6 |
* set of applicable methods
|
|
7 |
* @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java
|
|
8 |
*/
|
|
9 |
|
|
10 |
class TargetType21 {
|
|
11 |
interface SAM1 {
|
|
12 |
String m1(Integer n) throws Exception;
|
|
13 |
}
|
|
14 |
|
|
15 |
interface SAM2 {
|
|
16 |
void m2(Integer n);
|
|
17 |
}
|
|
18 |
|
|
19 |
interface SAM3<R,A> {
|
|
20 |
R m3(A n);
|
|
21 |
}
|
|
22 |
|
|
23 |
void call(SAM1 sam) { }
|
|
24 |
void call(SAM2 sam) { }
|
|
25 |
<R,A> void call(SAM3<R,A> sam) { }
|
|
26 |
|
|
27 |
void test() {
|
15038
|
28 |
call(x -> { throw new Exception(); }); //ambiguous
|
14547
|
29 |
call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2)
|
|
30 |
call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference
|
|
31 |
call(x -> { return null; }); ////ok - resolves to call(SAM1)
|
|
32 |
}
|
|
33 |
}
|