Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8034223
4 * @summary Most-specific testing for nested functional interface types
5 * @compile/fail/ref=MostSpecific14.out -XDrawDiagnostics MostSpecific14.java
6 */
7 class MostSpecific14 {
8 interface ToNumber { Number get(); }
9 interface ToToNumber { ToNumber get(); }
10 interface Factory<T> { T get(); }
12 void m1(Factory<Factory<Object>> f) {}
13 void m1(ToToNumber f) {}
15 void m2(Factory<Factory<Number>> f) {}
16 void m2(ToToNumber f) {}
18 void m3(Factory<Factory<Integer>> f) {}
19 void m3(ToToNumber f) {}
22 void test() {
23 m1(() -> () -> 23); // ok: choose ToToNumber
24 m2(() -> () -> 23); // error: ambiguous
25 m3(() -> () -> 23); // ok: choose Factory<Factory<Integer>>
27 m1(() -> this::getInteger); // ok: choose ToToNumber
28 m2(() -> this::getInteger); // error: ambiguous
29 m3(() -> this::getInteger); // ok: choose Factory<Factory<Integer>>
30 }
32 Integer getInteger() { return 23; }
33 }