1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/generics/diamond/pos/Pos03.java Wed Apr 14 12:31:55 2010 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +/* 1.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + */ 1.26 + 1.27 +/* 1.28 + * @test 1.29 + * @bug 6939620 1.30 + * 1.31 + * @summary Switch to 'complex' diamond inference scheme 1.32 + * @author mcimadamore 1.33 + * @compile Pos03.java 1.34 + * @run main Pos03 1.35 + * 1.36 + */ 1.37 + 1.38 +public class Pos03<U> { 1.39 + 1.40 + class Foo<V> { 1.41 + Foo(V x) {} 1.42 + <Z> Foo(V x, Z z) {} 1.43 + } 1.44 + 1.45 + void testSimple() { 1.46 + Foo<Integer> f1 = new Foo<>(1); 1.47 + Foo<? extends Integer> f2 = new Foo<>(1); 1.48 + Foo<?> f3 = new Foo<>(1); 1.49 + Foo<? super Integer> f4 = new Foo<>(1); 1.50 + 1.51 + Foo<Integer> f5 = new Foo<>(1){}; 1.52 + Foo<? extends Integer> f6 = new Foo<>(1){}; 1.53 + Foo<?> f7 = new Foo<>(1){}; 1.54 + Foo<? super Integer> f8 = new Foo<>(1){}; 1.55 + 1.56 + Foo<Integer> f9 = new Foo<>(1, ""); 1.57 + Foo<? extends Integer> f10 = new Foo<>(1, ""); 1.58 + Foo<?> f11 = new Foo<>(1, ""); 1.59 + Foo<? super Integer> f12 = new Foo<>(1, ""); 1.60 + 1.61 + Foo<Integer> f13 = new Foo<>(1, ""){}; 1.62 + Foo<? extends Integer> f14 = new Foo<>(1, ""){}; 1.63 + Foo<?> f15 = new Foo<>(1, ""){}; 1.64 + Foo<? super Integer> f16 = new Foo<>(1, ""){}; 1.65 + } 1.66 + 1.67 + void testQualified_1() { 1.68 + Foo<Integer> f1 = new Pos03<U>.Foo<>(1); 1.69 + Foo<? extends Integer> f2 = new Pos03<U>.Foo<>(1); 1.70 + Foo<?> f3 = new Pos03<U>.Foo<>(1); 1.71 + Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1); 1.72 + 1.73 + Foo<Integer> f5 = new Pos03<U>.Foo<>(1){}; 1.74 + Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1){}; 1.75 + Foo<?> f7 = new Pos03<U>.Foo<>(1){}; 1.76 + Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1){}; 1.77 + 1.78 + Foo<Integer> f9 = new Pos03<U>.Foo<>(1, ""); 1.79 + Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1, ""); 1.80 + Foo<?> f11 = new Pos03<U>.Foo<>(1, ""); 1.81 + Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1, ""); 1.82 + 1.83 + Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){}; 1.84 + Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){}; 1.85 + Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){}; 1.86 + Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){}; 1.87 + } 1.88 + 1.89 + void testQualified_2(Pos03<U> p) { 1.90 + Foo<Integer> f1 = p.new Foo<>(1); 1.91 + Foo<? extends Integer> f2 = p.new Foo<>(1); 1.92 + Foo<?> f3 = p.new Foo<>(1); 1.93 + Foo<? super Integer> f4 = p.new Foo<>(1); 1.94 + 1.95 + Foo<Integer> f5 = p.new Foo<>(1){}; 1.96 + Foo<? extends Integer> f6 = p.new Foo<>(1){}; 1.97 + Foo<?> f7 = p.new Foo<>(1){}; 1.98 + Foo<? super Integer> f8 = p.new Foo<>(1){}; 1.99 + 1.100 + Foo<Integer> f9 = p.new Foo<>(1, ""); 1.101 + Foo<? extends Integer> f10 = p.new Foo<>(1, ""); 1.102 + Foo<?> f11 = p.new Foo<>(1, ""); 1.103 + Foo<? super Integer> f12 = p.new Foo<>(1, ""); 1.104 + 1.105 + Foo<Integer> f13 = p.new Foo<>(1, ""){}; 1.106 + Foo<? extends Integer> f14 = p.new Foo<>(1, ""){}; 1.107 + Foo<?> f15 = p.new Foo<>(1, ""){}; 1.108 + Foo<? super Integer> f16 = p.new Foo<>(1, ""){}; 1.109 + } 1.110 + 1.111 + public static void main(String[] args) { 1.112 + Pos03<String> p3 = new Pos03<>(); 1.113 + p3.testSimple(); 1.114 + p3.testQualified_1(); 1.115 + p3.testQualified_2(p3); 1.116 + } 1.117 +}