Mon, 19 Jun 2017 14:51:25 -0700
Added tag jdk8u151-b02 for changeset 732e1bab2660
mcimadamore@1415 | 1 | /* |
mcimadamore@1415 | 2 | * @test /nodynamiccopyright/ |
mcimadamore@1415 | 3 | * @bug 8003280 |
mcimadamore@1415 | 4 | * @summary Add lambda tests |
mcimadamore@1415 | 5 | * check that candidates with cyclic type-inference are removed from the |
mcimadamore@1415 | 6 | * set of applicable methods |
mcimadamore@1415 | 7 | * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java |
mcimadamore@1415 | 8 | */ |
mcimadamore@1415 | 9 | |
mcimadamore@1415 | 10 | class TargetType21 { |
mcimadamore@1415 | 11 | interface SAM1 { |
mcimadamore@1415 | 12 | String m1(Integer n) throws Exception; |
mcimadamore@1415 | 13 | } |
mcimadamore@1415 | 14 | |
mcimadamore@1415 | 15 | interface SAM2 { |
mcimadamore@1415 | 16 | void m2(Integer n); |
mcimadamore@1415 | 17 | } |
mcimadamore@1415 | 18 | |
mcimadamore@1415 | 19 | interface SAM3<R,A> { |
mcimadamore@1415 | 20 | R m3(A n); |
mcimadamore@1415 | 21 | } |
mcimadamore@1415 | 22 | |
mcimadamore@1415 | 23 | void call(SAM1 sam) { } |
mcimadamore@1415 | 24 | void call(SAM2 sam) { } |
mcimadamore@1415 | 25 | <R,A> void call(SAM3<R,A> sam) { } |
mcimadamore@1415 | 26 | |
mcimadamore@1415 | 27 | void test() { |
mcimadamore@1480 | 28 | call(x -> { throw new Exception(); }); //ambiguous |
vromero@2000 | 29 | call((Integer x) -> { System.out.println(""); }); //ok (only one is void) |
vromero@2000 | 30 | call((Integer x) -> { return (Object) null; }); //ok (only one returns Object) |
mcimadamore@1510 | 31 | call(x -> { System.out.println(""); }); //ambiguous |
vromero@2000 | 32 | call(x -> { return (Object) null; }); //ambiguous |
mcimadamore@1510 | 33 | call(x -> { return null; }); //ambiguous |
mcimadamore@1415 | 34 | } |
mcimadamore@1415 | 35 | } |