author | mcimadamore |
Thu, 27 Aug 2009 13:40:48 +0100 | |
changeset 3765 | 9548183897cb |
child 5327 | cdc146f667c7 |
permissions | -rw-r--r-- |
3765
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
1 |
/* |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
3 |
* @bug 6840638 |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
4 |
* |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
5 |
* @summary Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond') |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
6 |
* @author mcimadamore |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
7 |
* @compile/fail/ref=Neg03.out Neg03.java -source 1.7 -XDrawDiagnostics |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
8 |
* |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
9 |
*/ |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
10 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
11 |
class Neg03<U> { |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
12 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
13 |
class Foo<V extends Number> { |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
14 |
Foo(V x) {} |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
15 |
<Z> Foo(V x, Z z) {} |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
16 |
} |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
17 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
18 |
void testSimple() { |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
19 |
Foo<String> f1 = new Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
20 |
Foo<? extends String> f2 = new Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
21 |
Foo<?> f3 = new Foo<>(""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
22 |
Foo<? super String> f4 = new Foo<>(""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
23 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
24 |
Foo<String> f5 = new Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
25 |
Foo<? extends String> f6 = new Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
26 |
Foo<?> f7 = new Foo<>(""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
27 |
Foo<? super String> f8 = new Foo<>(""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
28 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
29 |
Foo<String> f9 = new Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
30 |
Foo<? extends String> f10 = new Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
31 |
Foo<?> f11 = new Foo<>("", ""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
32 |
Foo<? super String> f12 = new Foo<>("", ""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
33 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
34 |
Foo<String> f13 = new Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
35 |
Foo<? extends String> f14 = new Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
36 |
Foo<?> f15 = new Foo<>("", ""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
37 |
Foo<? super String> f16 = new Foo<>("", ""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
38 |
} |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
39 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
40 |
void testQualified_1() { |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
41 |
Foo<String> f1 = new Neg03<U>.Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
42 |
Foo<? extends String> f2 = new Neg03<U>.Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
43 |
Foo<?> f3 = new Neg03<U>.Foo<>(""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
44 |
Foo<? super String> f4 = new Neg03<U>.Foo<>(""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
45 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
46 |
Foo<String> f5 = new Neg03<U>.Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
47 |
Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
48 |
Foo<?> f7 = new Neg03<U>.Foo<>(""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
49 |
Foo<? super String> f8 = new Neg03<U>.Foo<>(""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
50 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
51 |
Foo<String> f9 = new Neg03<U>.Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
52 |
Foo<? extends String> f10 = new Neg03<U>.Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
53 |
Foo<?> f11 = new Neg03<U>.Foo<>("", ""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
54 |
Foo<? super String> f12 = new Neg03<U>.Foo<>("", ""); //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
55 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
56 |
Foo<String> f13 = new Neg03<U>.Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
57 |
Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
58 |
Foo<?> f15 = new Neg03<U>.Foo<>("", ""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
59 |
Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){}; //new Foo<Object> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
60 |
} |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
61 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
62 |
void testQualified_2(Neg03<U> n) { |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
63 |
Foo<String> f1 = n.new Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
64 |
Foo<? extends String> f2 = n.new Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
65 |
Foo<?> f3 = n.new Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
66 |
Foo<? super String> f4 = n.new Foo<>(""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
67 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
68 |
Foo<String> f5 = n.new Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
69 |
Foo<? extends String> f6 = n.new Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
70 |
Foo<?> f7 = n.new Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
71 |
Foo<? super String> f8 = n.new Foo<>(""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
72 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
73 |
Foo<String> f9 = n.new Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
74 |
Foo<? extends String> f10 = n.new Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
75 |
Foo<?> f11 = n.new Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
76 |
Foo<? super String> f12 = n.new Foo<>("", ""); //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
77 |
|
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
78 |
Foo<String> f13 = n.new Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
79 |
Foo<? extends String> f14 = n.new Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
80 |
Foo<?> f15 = n.new Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
81 |
Foo<? super String> f16 = n.new Foo<>("", ""){}; //new Foo<Integer> created |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
82 |
} |
9548183897cb
6840638: Project Coin: Improved Type Inference for Generic Instance Creation (aka 'diamond')
mcimadamore
parents:
diff
changeset
|
83 |
} |