|
1 /* |
|
2 * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 6939620 |
|
27 * |
|
28 * @summary Switch to 'complex' diamond inference scheme |
|
29 * @author mcimadamore |
|
30 * @compile Pos02.java |
|
31 * @run main Pos02 |
|
32 */ |
|
33 |
|
34 public class Pos02 { |
|
35 |
|
36 static class Foo<X> { |
|
37 Foo(X x) {} |
|
38 <Z> Foo(X x, Z z) {} |
|
39 } |
|
40 |
|
41 void testSimple() { |
|
42 Foo<Integer> f1 = new Foo<>(1); |
|
43 Foo<? extends Integer> f2 = new Foo<>(1); |
|
44 Foo<?> f3 = new Foo<>(1); |
|
45 Foo<? super Integer> f4 = new Foo<>(1); |
|
46 |
|
47 Foo<Integer> f5 = new Foo<>(1){}; |
|
48 Foo<? extends Integer> f6 = new Foo<>(1){}; |
|
49 Foo<?> f7 = new Foo<>(1){}; |
|
50 Foo<? super Integer> f8 = new Foo<>(1){}; |
|
51 |
|
52 Foo<Integer> f9 = new Foo<>(1, ""); |
|
53 Foo<? extends Integer> f10 = new Foo<>(1, ""); |
|
54 Foo<?> f11 = new Foo<>(1, ""); |
|
55 Foo<? super Integer> f12 = new Foo<>(1, ""); |
|
56 |
|
57 Foo<Integer> f13 = new Foo<>(1, ""){}; |
|
58 Foo<? extends Integer> f14 = new Foo<>(1, ""){}; |
|
59 Foo<?> f15 = new Foo<>(1, ""){}; |
|
60 Foo<? super Integer> f16 = new Foo<>(1, ""){}; |
|
61 } |
|
62 |
|
63 void testQualified() { |
|
64 Foo<Integer> f1 = new Pos02.Foo<>(1); |
|
65 Foo<? extends Integer> f2 = new Pos02.Foo<>(1); |
|
66 Foo<?> f3 = new Pos02.Foo<>(1); |
|
67 Foo<? super Integer> f4 = new Pos02.Foo<>(1); |
|
68 |
|
69 Foo<Integer> f5 = new Pos02.Foo<>(1){}; |
|
70 Foo<? extends Integer> f6 = new Pos02.Foo<>(1){}; |
|
71 Foo<?> f7 = new Pos02.Foo<>(1){}; |
|
72 Foo<? super Integer> f8 = new Pos02.Foo<>(1){}; |
|
73 |
|
74 Foo<Integer> f9 = new Pos02.Foo<>(1, ""); |
|
75 Foo<? extends Integer> f10 = new Pos02.Foo<>(1, ""); |
|
76 Foo<?> f11 = new Pos02.Foo<>(1, ""); |
|
77 Foo<? super Integer> f12 = new Pos02.Foo<>(1, ""); |
|
78 |
|
79 Foo<Integer> f13 = new Pos02.Foo<>(1, ""){}; |
|
80 Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){}; |
|
81 Foo<?> f15 = new Pos02.Foo<>(1, ""){}; |
|
82 Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){}; |
|
83 } |
|
84 |
|
85 public static void main(String[] args) { |
|
86 Pos02 p2 = new Pos02(); |
|
87 p2.testSimple(); |
|
88 p2.testQualified(); |
|
89 } |
|
90 } |