Wed, 14 Apr 2010 12:31:55 +0100
6939620: Switch to 'complex' diamond inference scheme
Summary: Implement new inference scheme for diamond operator that takes into account type of actual arguments supplied to constructor
Reviewed-by: jjg, darcy
mcimadamore@537 | 1 | /* |
mcimadamore@537 | 2 | * @test /nodynamiccopyright/ |
mcimadamore@537 | 3 | * @bug 6939620 |
mcimadamore@537 | 4 | * |
mcimadamore@537 | 5 | * @summary Switch to 'complex' diamond inference scheme |
mcimadamore@537 | 6 | * @author mcimadamore |
mcimadamore@537 | 7 | * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics |
mcimadamore@537 | 8 | * |
mcimadamore@537 | 9 | */ |
mcimadamore@537 | 10 | |
mcimadamore@537 | 11 | class Neg03<U> { |
mcimadamore@537 | 12 | |
mcimadamore@537 | 13 | class Foo<V extends Number> { |
mcimadamore@537 | 14 | Foo(V x) {} |
mcimadamore@537 | 15 | <Z> Foo(V x, Z z) {} |
mcimadamore@537 | 16 | } |
mcimadamore@537 | 17 | |
mcimadamore@537 | 18 | void testSimple() { |
mcimadamore@537 | 19 | Foo<String> f1 = new Foo<>(""); |
mcimadamore@537 | 20 | Foo<? extends String> f2 = new Foo<>(""); |
mcimadamore@537 | 21 | Foo<?> f3 = new Foo<>(""); |
mcimadamore@537 | 22 | Foo<? super String> f4 = new Foo<>(""); |
mcimadamore@537 | 23 | |
mcimadamore@537 | 24 | Foo<String> f5 = new Foo<>(""){}; |
mcimadamore@537 | 25 | Foo<? extends String> f6 = new Foo<>(""){}; |
mcimadamore@537 | 26 | Foo<?> f7 = new Foo<>(""){}; |
mcimadamore@537 | 27 | Foo<? super String> f8 = new Foo<>(""){}; |
mcimadamore@537 | 28 | |
mcimadamore@537 | 29 | Foo<String> f9 = new Foo<>("", ""); |
mcimadamore@537 | 30 | Foo<? extends String> f10 = new Foo<>("", ""); |
mcimadamore@537 | 31 | Foo<?> f11 = new Foo<>("", ""); |
mcimadamore@537 | 32 | Foo<? super String> f12 = new Foo<>("", ""); |
mcimadamore@537 | 33 | |
mcimadamore@537 | 34 | Foo<String> f13 = new Foo<>("", ""){}; |
mcimadamore@537 | 35 | Foo<? extends String> f14 = new Foo<>("", ""){}; |
mcimadamore@537 | 36 | Foo<?> f15 = new Foo<>("", ""){}; |
mcimadamore@537 | 37 | Foo<? super String> f16 = new Foo<>("", ""){}; |
mcimadamore@537 | 38 | } |
mcimadamore@537 | 39 | |
mcimadamore@537 | 40 | void testQualified_1() { |
mcimadamore@537 | 41 | Foo<String> f1 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 42 | Foo<? extends String> f2 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 43 | Foo<?> f3 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 44 | Foo<? super String> f4 = new Neg03<U>.Foo<>(""); |
mcimadamore@537 | 45 | |
mcimadamore@537 | 46 | Foo<String> f5 = new Neg03<U>.Foo<>(""){}; |
mcimadamore@537 | 47 | Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){}; |
mcimadamore@537 | 48 | Foo<?> f7 = new Neg03<U>.Foo<>(""){}; |
mcimadamore@537 | 49 | Foo<? super String> f8 = new Neg03<U>.Foo<>(""){}; |
mcimadamore@537 | 50 | |
mcimadamore@537 | 51 | Foo<String> f9 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@537 | 52 | Foo<? extends String> f10 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@537 | 53 | Foo<?> f11 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@537 | 54 | Foo<? super String> f12 = new Neg03<U>.Foo<>("", ""); |
mcimadamore@537 | 55 | |
mcimadamore@537 | 56 | Foo<String> f13 = new Neg03<U>.Foo<>("", ""){}; |
mcimadamore@537 | 57 | Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){}; |
mcimadamore@537 | 58 | Foo<?> f15 = new Neg03<U>.Foo<>("", ""){}; |
mcimadamore@537 | 59 | Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){}; |
mcimadamore@537 | 60 | } |
mcimadamore@537 | 61 | |
mcimadamore@537 | 62 | void testQualified_2(Neg03<U> n) { |
mcimadamore@537 | 63 | Foo<String> f1 = n.new Foo<>(""); |
mcimadamore@537 | 64 | Foo<? extends String> f2 = n.new Foo<>(""); |
mcimadamore@537 | 65 | Foo<?> f3 = n.new Foo<>(""); |
mcimadamore@537 | 66 | Foo<? super String> f4 = n.new Foo<>(""); |
mcimadamore@537 | 67 | |
mcimadamore@537 | 68 | Foo<String> f5 = n.new Foo<>(""){}; |
mcimadamore@537 | 69 | Foo<? extends String> f6 = n.new Foo<>(""){}; |
mcimadamore@537 | 70 | Foo<?> f7 = n.new Foo<>(""){}; |
mcimadamore@537 | 71 | Foo<? super String> f8 = n.new Foo<>(""){}; |
mcimadamore@537 | 72 | |
mcimadamore@537 | 73 | Foo<String> f9 = n.new Foo<>("", ""); |
mcimadamore@537 | 74 | Foo<? extends String> f10 = n.new Foo<>("", ""); |
mcimadamore@537 | 75 | Foo<?> f11 = n.new Foo<>("", ""); |
mcimadamore@537 | 76 | Foo<? super String> f12 = n.new Foo<>("", ""); |
mcimadamore@537 | 77 | |
mcimadamore@537 | 78 | Foo<String> f13 = n.new Foo<>("", ""){}; |
mcimadamore@537 | 79 | Foo<? extends String> f14 = n.new Foo<>("", ""){}; |
mcimadamore@537 | 80 | Foo<?> f15 = n.new Foo<>("", ""){}; |
mcimadamore@537 | 81 | Foo<? super String> f16 = n.new Foo<>("", ""){}; |
mcimadamore@537 | 82 | } |
mcimadamore@537 | 83 | } |