test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.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 8003280
     4  * @summary Add lambda tests
     5  *   Overloaded methods take raw SAM types that have type inference according to SAM descriptor
     6              should have ambiguous resolution of method
     7  * @compile/fail/ref=InferenceTest_neg1_2.out -XDrawDiagnostics InferenceTest_neg1_2.java
     8  */
    10 public class InferenceTest_neg1_2 {
    12     public static void main(String[] args) {
    13         InferenceTest_neg1_2 test = new InferenceTest_neg1_2();
    14         test.method(n -> null); //method 1-5 all match
    15         test.method(n -> "a"); //method 2, 4 match
    16         test.method(n -> 0); //method 1, 3, 5 match
    17     }
    19     void method(SAM1 s) { //method 1
    20         Integer i = s.foo("a");
    21     }
    23     void method(SAM2 s) { //method 2
    24         String str = s.foo(0);
    25     }
    27     void method(SAM3<Integer> s) { //method 3
    28         Integer i = s.get(0);
    29     }
    31     void method(SAM4<Double, String> s) { //method 4
    32         String str = s.get(0.0);
    33     }
    35     void method(SAM5<Integer> s) { //method 5
    36         Integer i = s.get(0.0);
    37     }
    39     interface SAM1 {
    40         Integer foo(String a);
    41     }
    43     interface SAM2 {
    44         String foo(Integer a);
    45     }
    47     interface SAM3<T> {
    48         T get(T t);
    49     }
    51     interface SAM4<T, V> {
    52         V get(T t);
    53     }
    55     interface SAM5<T> {
    56         T get(Double i);
    57     }
    58 }

mercurial