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