Thu, 31 Aug 2017 15:17:03 +0800
merge
1 /*
2 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. 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 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.
22 */
24 /*
25 * @test
26 * @bug 6939620 7020044
27 *
28 * @summary basic test for diamond (simple/qualified type-expressions, member inner)
29 * @author mcimadamore
30 * @compile Pos03.java
31 * @run main Pos03
32 *
33 */
35 public class Pos03<U> {
37 class Foo<V> {
38 Foo(V x) {}
39 <Z> Foo(V x, Z z) {}
40 }
42 void testSimple() {
43 Foo<Integer> f1 = new Foo<>(1);
44 Foo<? extends Integer> f2 = new Foo<>(1);
45 Foo<?> f3 = new Foo<>(1);
46 Foo<? super Integer> f4 = new Foo<>(1);
48 Foo<Integer> f5 = new Foo<>(1, "");
49 Foo<? extends Integer> f6 = new Foo<>(1, "");
50 Foo<?> f7 = new Foo<>(1, "");
51 Foo<? super Integer> f8 = new Foo<>(1, "");
52 }
54 void testQualified_1() {
55 Foo<Integer> f1 = new Pos03<U>.Foo<>(1);
56 Foo<? extends Integer> f2 = new Pos03<U>.Foo<>(1);
57 Foo<?> f3 = new Pos03<U>.Foo<>(1);
58 Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1);
60 Foo<Integer> f5 = new Pos03<U>.Foo<>(1, "");
61 Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1, "");
62 Foo<?> f7 = new Pos03<U>.Foo<>(1, "");
63 Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1, "");
64 }
66 void testQualified_2(Pos03<U> p) {
67 Foo<Integer> f1 = p.new Foo<>(1);
68 Foo<? extends Integer> f2 = p.new Foo<>(1);
69 Foo<?> f3 = p.new Foo<>(1);
70 Foo<? super Integer> f4 = p.new Foo<>(1);
72 Foo<Integer> f5 = p.new Foo<>(1, "");
73 Foo<? extends Integer> f6 = p.new Foo<>(1, "");
74 Foo<?> f7 = p.new Foo<>(1, "");
75 Foo<? super Integer> f8 = p.new Foo<>(1, "");
76 }
78 public static void main(String[] args) {
79 Pos03<String> p3 = new Pos03<>();
80 p3.testSimple();
81 p3.testQualified_1();
82 p3.testQualified_2(p3);
83 }
84 }