test/tools/javac/lambda/8016177/T8016177c.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 8016081 8016178
     4  * @summary structural most specific and stuckness
     5  * @compile/fail/ref=T8016177c.out -XDrawDiagnostics T8016177c.java
     6  */
     8 class T8016177c {
    10     interface Function<X, Y> {
    11         Y m(X x);
    12     }
    14     interface ExtFunction<X, Y> extends Function<X, Y> { }
    16     <U, V> U m1(Function<U, V> f) { return null; }
    17     <U, V> U m1(ExtFunction<U, V> f) { return null; }
    19     void m2(Function<Integer, Integer> f) { }
    20     void m2(ExtFunction<Integer, Integer> f) { }
    22     void m3(Function<Integer, Integer> f) { }
    23     void m3(ExtFunction<Object, Integer> f) { }
    25     int g1(Object s) { return 1; }
    27     int g2(Number s) { return 1; }
    28     int g2(Object s) { return 1; }
    30     void test() {
    31         m1((Integer x)->x); //ok - explicit lambda - subtyping picks most specific
    32         m2((Integer x)->x); //ok - explicit lambda - subtyping picks most specific
    33         m3((Integer x)->x); //ok - explicit lambda (only one applicable)
    35         m1(x->1); //ok - stuck lambda but nominal most specific wins
    36         m2(x->1); //ok - stuck lambda but nominal most specific wins
    37         m3(x->1); //ambiguous - implicit lambda & different params
    39         m1(this::g1); //ok - unambiguous ref - subtyping picks most specific
    40         m2(this::g1); //ok - unambiguous ref - subtyping picks most specific
    41         m3(this::g1); //ambiguous - both applicable, neither most specific
    43         m1(this::g2); //ok - stuck mref but nominal most specific wins
    44         m2(this::g2); //ok - stuck mref but nominal most specific wins
    45         m3(this::g2); //ambiguous - different params
    46     }
    47 }

mercurial