/
githubmirror
/
panama-vector
Обзор
Документация
Войти
/
githubmirror
/
panama-vector
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/langtools/tools/javac/lambda/MostSpecific14.java
33 строки
1001 B
Erik Joelsson
8187443: Forest Consolidation: Move files to unified layout
12 сен 2017, 20:03
12 сен 2017, 20:03
3789983
Код
Авторство
О чём код?
/* * @test /nodynamiccopyright/ * @bug 8034223 * @summary Most-specific testing for nested functional interface types * @compile/fail/ref=MostSpecific14.out -XDrawDiagnostics MostSpecific14.java */ class MostSpecific14 { interface ToNumber { Number get(); } interface ToToNumber { ToNumber get(); } interface Factory<T> { T get(); } void m1(Factory<Factory<Object>> f) {} void m1(ToToNumber f) {} void m2(Factory<Factory<Number>> f) {} void m2(ToToNumber f) {} void m3(Factory<Factory<Integer>> f) {} void m3(ToToNumber f) {} void test() { m1(() -> () -> 23); // ok: choose ToToNumber m2(() -> () -> 23); // error: ambiguous m3(() -> () -> 23); // ok: choose Factory<Factory<Integer>> m1(() -> this::getInteger); // ok: choose ToToNumber m2(() -> this::getInteger); // error: ambiguous m3(() -> this::getInteger); // ok: choose Factory<Factory<Integer>> } Integer getInteger() { return 23; } }