test/tools/javac/generics/diamond/neg/Neg02.java

Wed, 27 Jul 2011 19:01:08 +0100

author
mcimadamore
date
Wed, 27 Jul 2011 19:01:08 +0100
changeset 1060
d5f33267a06d
parent 914
ca32f2986301
child 2525
2eb010b6cb22
permissions
-rw-r--r--

7046778: Project Coin: problem with diamond and member inner classes
Summary: Diamond inference generates spurious error messages when target type is a member inner class
Reviewed-by: jjg

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 6939620 7020044
     4  *
     5  * @summary  Check that diamond fails when inference violates declared bounds
     6  *           (test with nested class, qualified/simple type expressions)
     7  * @author mcimadamore
     8  * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics
     9  *
    10  */
    12 class Neg02 {
    14     static class Foo<X extends Number> {
    15         Foo(X x) {}
    16         <Z> Foo(X x, Z z) {}
    17     }
    19     void testSimple() {
    20         Foo<String> f1 = new Foo<>("");
    21         Foo<? extends String> f2 = new Foo<>("");
    22         Foo<?> f3 = new Foo<>("");
    23         Foo<? super String> f4 = new Foo<>("");
    25         Foo<String> f5 = new Foo<>("", "");
    26         Foo<? extends String> f6 = new Foo<>("", "");
    27         Foo<?> f7 = new Foo<>("", "");
    28         Foo<? super String> f8 = new Foo<>("", "");
    29     }
    31     void testQualified() {
    32         Foo<String> f1 = new Neg02.Foo<>("");
    33         Foo<? extends String> f2 = new Neg02.Foo<>("");
    34         Foo<?> f3 = new Neg02.Foo<>("");
    35         Foo<? super String> f4 = new Neg02.Foo<>("");
    37         Foo<String> f5 = new Neg02.Foo<>("", "");
    38         Foo<? extends String> f6 = new Neg02.Foo<>("", "");
    39         Foo<?> f7 = new Neg02.Foo<>("", "");
    40         Foo<? super String> f8 = new Neg02.Foo<>("", "");
    41     }
    42 }

mercurial