author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 29776 | langtools/test/tools/javac/generics/diamond/pos/Pos01.java@984a79b71cfe |
permissions | -rw-r--r-- |
5321
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
1 |
/* |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
2 |
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. |
5321
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
4 |
* |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
8 |
* |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
14 |
* |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
18 |
* |
5520 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
5321
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
23 |
|
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
24 |
/* |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
26 |
* @bug 6939620 7020044 8062373 |
5321
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
27 |
* |
8635
383a416a2bdf
7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents:
5520
diff
changeset
|
28 |
* @summary basic test for diamond (generic/non-generic constructors) |
5321
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
29 |
* @author mcimadamore |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
30 |
* @compile Pos01.java |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
31 |
* @run main Pos01 |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
32 |
* |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
33 |
*/ |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
34 |
|
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
35 |
public class Pos01<X> { |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
36 |
|
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
37 |
Pos01(X x) {} |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
38 |
|
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
39 |
<Z> Pos01(X x, Z z) {} |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
40 |
|
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
41 |
void test() { |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
42 |
Pos01<Integer> p1 = new Pos01<>(1); |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
43 |
Pos01<? extends Integer> p2 = new Pos01<>(1); |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
44 |
Pos01<?> p3 = new Pos01<>(1); |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
45 |
Pos01<? super Integer> p4 = new Pos01<>(1); |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
46 |
|
8635
383a416a2bdf
7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents:
5520
diff
changeset
|
47 |
Pos01<Integer> p5 = new Pos01<>(1, ""); |
383a416a2bdf
7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents:
5520
diff
changeset
|
48 |
Pos01<? extends Integer> p6 = new Pos01<>(1, ""); |
383a416a2bdf
7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents:
5520
diff
changeset
|
49 |
Pos01<?> p7 = new Pos01<>(1, ""); |
383a416a2bdf
7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents:
5520
diff
changeset
|
50 |
Pos01<? super Integer> p8 = new Pos01<>(1, ""); |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
51 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
52 |
Pos01<Integer> p9 = new Pos01<>(1){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
53 |
Pos01<? extends Integer> p10 = new Pos01<>(1){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
54 |
Pos01<?> p11 = new Pos01<>(1){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
55 |
Pos01<? super Integer> p12 = new Pos01<>(1){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
56 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
57 |
Pos01<Integer> p13 = new Pos01<>(1, ""){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
58 |
Pos01<? extends Integer> p14= new Pos01<>(1, ""){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
59 |
Pos01<?> p15 = new Pos01<>(1, ""){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
60 |
Pos01<? super Integer> p16 = new Pos01<>(1, ""){}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
8635
diff
changeset
|
61 |
} |
5321
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
62 |
|
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
63 |
public static void main(String[] args) { |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
64 |
Pos01<String> p1 = new Pos01<>(""); |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
65 |
p1.test(); |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
66 |
} |
c8efe769cb3b
6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff
changeset
|
67 |
} |