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 8034223 |
aoqi@0 | 4 | * @summary Most-specific testing for nested functional interface types |
aoqi@0 | 5 | * @compile/fail/ref=MostSpecific14.out -XDrawDiagnostics MostSpecific14.java |
aoqi@0 | 6 | */ |
aoqi@0 | 7 | class MostSpecific14 { |
aoqi@0 | 8 | interface ToNumber { Number get(); } |
aoqi@0 | 9 | interface ToToNumber { ToNumber get(); } |
aoqi@0 | 10 | interface Factory<T> { T get(); } |
aoqi@0 | 11 | |
aoqi@0 | 12 | void m1(Factory<Factory<Object>> f) {} |
aoqi@0 | 13 | void m1(ToToNumber f) {} |
aoqi@0 | 14 | |
aoqi@0 | 15 | void m2(Factory<Factory<Number>> f) {} |
aoqi@0 | 16 | void m2(ToToNumber f) {} |
aoqi@0 | 17 | |
aoqi@0 | 18 | void m3(Factory<Factory<Integer>> f) {} |
aoqi@0 | 19 | void m3(ToToNumber f) {} |
aoqi@0 | 20 | |
aoqi@0 | 21 | |
aoqi@0 | 22 | void test() { |
aoqi@0 | 23 | m1(() -> () -> 23); // ok: choose ToToNumber |
aoqi@0 | 24 | m2(() -> () -> 23); // error: ambiguous |
aoqi@0 | 25 | m3(() -> () -> 23); // ok: choose Factory<Factory<Integer>> |
aoqi@0 | 26 | |
aoqi@0 | 27 | m1(() -> this::getInteger); // ok: choose ToToNumber |
aoqi@0 | 28 | m2(() -> this::getInteger); // error: ambiguous |
aoqi@0 | 29 | m3(() -> this::getInteger); // ok: choose Factory<Factory<Integer>> |
aoqi@0 | 30 | } |
aoqi@0 | 31 | |
aoqi@0 | 32 | Integer getInteger() { return 23; } |
aoqi@0 | 33 | } |