Mon, 26 Mar 2012 15:28:22 +0100
7151492: Encapsulate check logic into Attr.ResultInfo
Summary: ResultInfo class should be used to make attribution code transparent w.r.t. check logic being used
Reviewed-by: jjg, dlsmith
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 inner class, qualified/simple type expressions) |
mcimadamore@537 | 7 | * @author mcimadamore |
mcimadamore@537 | 8 | * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics |
mcimadamore@537 | 9 | * |
mcimadamore@537 | 10 | */ |
mcimadamore@537 | 11 | |
mcimadamore@537 | 12 | class Neg03<U> { |
mcimadamore@537 | 13 | |
mcimadamore@537 | 14 | class Foo<V extends Number> { |
mcimadamore@537 | 15 | Foo(V x) {} |
mcimadamore@537 | 16 | <Z> Foo(V 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_1() { |
mcimadamore@537 | 32 | Foo<String> f1 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 33 | Foo<? extends String> f2 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 34 | Foo<?> f3 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 35 | Foo<? super String> f4 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 36 | |
mcimadamore@914 | 37 | Foo<String> f5 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@914 | 38 | Foo<? extends String> f6 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@914 | 39 | Foo<?> f7 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@914 | 40 | Foo<? super String> f8 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@537 | 41 | } |
mcimadamore@537 | 42 | |
mcimadamore@537 | 43 | void testQualified_2(Neg03<U> n) { |
mcimadamore@537 | 44 | Foo<String> f1 = n.new Foo<>(""); |
mcimadamore@537 | 45 | Foo<? extends String> f2 = n.new Foo<>(""); |
mcimadamore@537 | 46 | Foo<?> f3 = n.new Foo<>(""); |
mcimadamore@537 | 47 | Foo<? super String> f4 = n.new Foo<>(""); |
mcimadamore@537 | 48 | |
mcimadamore@914 | 49 | Foo<String> f5 = n.new Foo<>("", ""); |
mcimadamore@914 | 50 | Foo<? extends String> f6 = n.new Foo<>("", ""); |
mcimadamore@914 | 51 | Foo<?> f7 = n.new Foo<>("", ""); |
mcimadamore@914 | 52 | Foo<? super String> f8 = n.new Foo<>("", ""); |
mcimadamore@537 | 53 | } |
mcimadamore@537 | 54 | } |