|
1 /* |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 8003280 |
|
4 * @summary Add lambda tests |
|
5 * check that candidates with incompatible SAM descriptor args length |
|
6 are removed from the set of applicable methods |
|
7 * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java |
|
8 */ |
|
9 |
|
10 class TargetType22 { |
|
11 |
|
12 interface Sam0 { |
|
13 void m(); |
|
14 } |
|
15 |
|
16 interface Sam1<A> { |
|
17 void m(A a); |
|
18 } |
|
19 |
|
20 interface Sam2<A> { |
|
21 void m(A a1, A a2); |
|
22 } |
|
23 |
|
24 interface Sam3<A> { |
|
25 void m(A a1, A a2, A a3); |
|
26 } |
|
27 |
|
28 interface SamX<A> { |
|
29 void m(A... as); |
|
30 } |
|
31 |
|
32 void call(Sam0 s) { } |
|
33 void call(Sam1<String> s) { } |
|
34 void call(Sam2<String> s) { } |
|
35 void call(Sam3<String> s) { } |
|
36 void call(SamX<String> s) { } |
|
37 |
|
38 void test() { |
|
39 call(() -> { }); |
|
40 call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match |
|
41 call((a1, a2) -> { }); |
|
42 call((a1, a2, a3) -> { }); |
|
43 } |
|
44 } |