langtools/test/tools/javac/generics/diamond/pos/Pos04.java
changeset 5320 e2aaa958b02d
parent 5319 63dc7f367a37
child 5321 c8efe769cb3b
equal deleted inserted replaced
5319:63dc7f367a37 5320:e2aaa958b02d
     1 /*
       
     2  * @test /nodynamiccopyright/
       
     3  * @bug 6840638
       
     4  *
       
     5  * @summary  Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
       
     6  * @author mcimadamore
       
     7  * @compile Pos04.java -source 1.7
       
     8  * @run main Pos04
       
     9  *
       
    10  */
       
    11 
       
    12 public class Pos04<U> {
       
    13 
       
    14     void test() {
       
    15         class Foo<V> {
       
    16             Foo(V x) {}
       
    17             <Z> Foo(V x, Z z) {}
       
    18         }
       
    19         Foo<Integer> p1 = new Foo<>(1); //new Foo<Integer> created
       
    20         Foo<? extends Integer> p2 = new Foo<>(1); //new Foo<Integer> created
       
    21         Foo<?> p3 = new Foo<>(1); //new Foo<Object> created
       
    22         Foo<? super Integer> p4 = new Foo<>(1); //new Foo<Object> created
       
    23 
       
    24         Foo<Integer> p5 = new Foo<>(1){}; //new Foo<Integer> created
       
    25         Foo<? extends Integer> p6 = new Foo<>(1){}; //new Foo<Integer> created
       
    26         Foo<?> p7 = new Foo<>(1){}; //new Foo<Object> created
       
    27         Foo<? super Integer> p8 = new Foo<>(1){}; //new Foo<Object> created
       
    28 
       
    29         Foo<Integer> p9 = new Foo<>(1, ""); //new Foo<Integer> created
       
    30         Foo<? extends Integer> p10 = new Foo<>(1, ""); //new Foo<Integer> created
       
    31         Foo<?> p11 = new Foo<>(1, ""); //new Foo<Object> created
       
    32         Foo<? super Integer> p12 = new Foo<>(1, ""); //new Foo<Object> created
       
    33 
       
    34         Foo<Integer> p13 = new Foo<>(1, ""){}; //new Foo<Integer> created
       
    35         Foo<? extends Integer> p14 = new Foo<>(1, ""){}; //new Foo<Integer> created
       
    36         Foo<?> p15 = new Foo<>(1, ""){}; //new Foo<Object> created
       
    37         Foo<? super Integer> p16 = new Foo<>(1, ""){}; //new Foo<Object> created
       
    38     }
       
    39 
       
    40     public static void main(String[] args) {
       
    41         Pos04<String> p4 = new Pos04<>();
       
    42         p4.test();
       
    43     }
       
    44 }