Mon, 07 Mar 2011 14:31:50 +0000
7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
Summary: Disallow diamond on anonymous innner class creation expression (as per JSR 334's EDR)
Reviewed-by: jjg
mcimadamore@537 | 1 | /* |
mcimadamore@537 | 2 | * @test /nodynamiccopyright/ |
mcimadamore@914 | 3 | * @bug 6939620 7020044 |
mcimadamore@537 | 4 | * |
mcimadamore@914 | 5 | * @summary Check that diamond fails when inference violates declared bounds |
mcimadamore@914 | 6 | * (test with nested class, qualified/simple type expressions) |
mcimadamore@537 | 7 | * @author mcimadamore |
mcimadamore@537 | 8 | * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics |
mcimadamore@537 | 9 | * |
mcimadamore@537 | 10 | */ |
mcimadamore@537 | 11 | |
mcimadamore@537 | 12 | class Neg02 { |
mcimadamore@537 | 13 | |
mcimadamore@537 | 14 | static class Foo<X extends Number> { |
mcimadamore@537 | 15 | Foo(X x) {} |
mcimadamore@537 | 16 | <Z> Foo(X x, Z z) {} |
mcimadamore@537 | 17 | } |
mcimadamore@537 | 18 | |
mcimadamore@537 | 19 | void testSimple() { |
mcimadamore@537 | 20 | Foo<String> f1 = new Foo<>(""); |
mcimadamore@537 | 21 | Foo<? extends String> f2 = new Foo<>(""); |
mcimadamore@537 | 22 | Foo<?> f3 = new Foo<>(""); |
mcimadamore@537 | 23 | Foo<? super String> f4 = new Foo<>(""); |
mcimadamore@537 | 24 | |
mcimadamore@914 | 25 | Foo<String> f5 = new Foo<>("", ""); |
mcimadamore@914 | 26 | Foo<? extends String> f6 = new Foo<>("", ""); |
mcimadamore@914 | 27 | Foo<?> f7 = new Foo<>("", ""); |
mcimadamore@914 | 28 | Foo<? super String> f8 = new Foo<>("", ""); |
mcimadamore@537 | 29 | } |
mcimadamore@537 | 30 | |
mcimadamore@537 | 31 | void testQualified() { |
mcimadamore@537 | 32 | Foo<String> f1 = new Neg02.Foo<>(""); |
mcimadamore@537 | 33 | Foo<? extends String> f2 = new Neg02.Foo<>(""); |
mcimadamore@537 | 34 | Foo<?> f3 = new Neg02.Foo<>(""); |
mcimadamore@537 | 35 | Foo<? super String> f4 = new Neg02.Foo<>(""); |
mcimadamore@537 | 36 | |
mcimadamore@914 | 37 | Foo<String> f5 = new Neg02.Foo<>("", ""); |
mcimadamore@914 | 38 | Foo<? extends String> f6 = new Neg02.Foo<>("", ""); |
mcimadamore@914 | 39 | Foo<?> f7 = new Neg02.Foo<>("", ""); |
mcimadamore@914 | 40 | Foo<? super String> f8 = new Neg02.Foo<>("", ""); |
mcimadamore@537 | 41 | } |
mcimadamore@537 | 42 | } |