test/tools/javac/lambda/MostSpecific14.java

Fri, 30 May 2014 12:54:16 +0200

author
jlahoda
date
Fri, 30 May 2014 12:54:16 +0200
changeset 2410
e64bb2f5f0cf
parent 0
959103a6100f
permissions
-rw-r--r--

8031967: For some sources compiler compiles for ever
Summary: Avoid creating DeferredTypes for method calls with method calls as receivers if the site can be determined reliably
Reviewed-by: mcimadamore, vromero
Contributed-by: maurizio.cimadamore@oracle.com, jan.lahoda@oracle.com

     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 }

mercurial