Pos03.java revision 542:97b6fa97b8dd
144963Sjb/* 244963Sjb * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 344963Sjb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 444963Sjb * 544963Sjb * This code is free software; you can redistribute it and/or modify it 644963Sjb * under the terms of the GNU General Public License version 2 only, as 744963Sjb * published by the Free Software Foundation. 844963Sjb * 944963Sjb * This code is distributed in the hope that it will be useful, but WITHOUT 1044963Sjb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1144963Sjb * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1244963Sjb * version 2 for more details (a copy is included in the LICENSE file that 1344963Sjb * accompanied this code). 1444963Sjb * 1544963Sjb * You should have received a copy of the GNU General Public License version 1644963Sjb * 2 along with this work; if not, write to the Free Software Foundation, 1744963Sjb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1844963Sjb * 1944963Sjb * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2044963Sjb * CA 95054 USA or visit www.sun.com if you need additional information or 2144963Sjb * have any questions. 2244963Sjb */ 2349439Sdeischen 2444963Sjb/* 2544963Sjb * @test 2644963Sjb * @bug 6939620 2744963Sjb * 2844963Sjb * @summary Switch to 'complex' diamond inference scheme 2944963Sjb * @author mcimadamore 3044963Sjb * @compile Pos03.java 3144963Sjb * @run main Pos03 3250476Speter * 3344963Sjb */ 34174112Sdeischen 35174112Sdeischenpublic class Pos03<U> { 3698976Sdeischen 3798976Sdeischen class Foo<V> { 3898976Sdeischen Foo(V x) {} 3944963Sjb <Z> Foo(V x, Z z) {} 4044963Sjb } 4144963Sjb 42174112Sdeischen void testSimple() { 43103388Smini Foo<Integer> f1 = new Foo<>(1); 4444963Sjb Foo<? extends Integer> f2 = new Foo<>(1); 45174112Sdeischen Foo<?> f3 = new Foo<>(1); 46174112Sdeischen Foo<? super Integer> f4 = new Foo<>(1); 4775369Sdeischen 4871581Sdeischen Foo<Integer> f5 = new Foo<>(1){}; 4944963Sjb Foo<? extends Integer> f6 = new Foo<>(1){}; 5098976Sdeischen Foo<?> f7 = new Foo<>(1){}; 5144963Sjb Foo<? super Integer> f8 = new Foo<>(1){}; 5298976Sdeischen 53113658Sdeischen Foo<Integer> f9 = new Foo<>(1, ""); 54117300Sdavidxu Foo<? extends Integer> f10 = new Foo<>(1, ""); 5544963Sjb Foo<?> f11 = new Foo<>(1, ""); 5644963Sjb Foo<? super Integer> f12 = new Foo<>(1, ""); 5744963Sjb 5844963Sjb Foo<Integer> f13 = new Foo<>(1, ""){}; 5944963Sjb Foo<? extends Integer> f14 = new Foo<>(1, ""){}; 6044963Sjb Foo<?> f15 = new Foo<>(1, ""){}; 6144963Sjb Foo<? super Integer> f16 = new Foo<>(1, ""){}; 6244963Sjb } 63119063Sdavidxu 64117706Sdavidxu void testQualified_1() { 65116977Sdavidxu Foo<Integer> f1 = new Pos03<U>.Foo<>(1); 66116977Sdavidxu Foo<? extends Integer> f2 = new Pos03<U>.Foo<>(1); 67116977Sdavidxu Foo<?> f3 = new Pos03<U>.Foo<>(1); 68117300Sdavidxu Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1); 69116977Sdavidxu 70113658Sdeischen Foo<Integer> f5 = new Pos03<U>.Foo<>(1){}; 71117300Sdavidxu Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1){}; 72113658Sdeischen Foo<?> f7 = new Pos03<U>.Foo<>(1){}; 73113658Sdeischen Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1){}; 74117300Sdavidxu 7544963Sjb Foo<Integer> f9 = new Pos03<U>.Foo<>(1, ""); 7644963Sjb Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1, ""); 7744963Sjb Foo<?> f11 = new Pos03<U>.Foo<>(1, ""); 7844963Sjb Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1, ""); 79 80 Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){}; 81 Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){}; 82 Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){}; 83 Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){}; 84 } 85 86 void testQualified_2(Pos03<U> p) { 87 Foo<Integer> f1 = p.new Foo<>(1); 88 Foo<? extends Integer> f2 = p.new Foo<>(1); 89 Foo<?> f3 = p.new Foo<>(1); 90 Foo<? super Integer> f4 = p.new Foo<>(1); 91 92 Foo<Integer> f5 = p.new Foo<>(1){}; 93 Foo<? extends Integer> f6 = p.new Foo<>(1){}; 94 Foo<?> f7 = p.new Foo<>(1){}; 95 Foo<? super Integer> f8 = p.new Foo<>(1){}; 96 97 Foo<Integer> f9 = p.new Foo<>(1, ""); 98 Foo<? extends Integer> f10 = p.new Foo<>(1, ""); 99 Foo<?> f11 = p.new Foo<>(1, ""); 100 Foo<? super Integer> f12 = p.new Foo<>(1, ""); 101 102 Foo<Integer> f13 = p.new Foo<>(1, ""){}; 103 Foo<? extends Integer> f14 = p.new Foo<>(1, ""){}; 104 Foo<?> f15 = p.new Foo<>(1, ""){}; 105 Foo<? super Integer> f16 = p.new Foo<>(1, ""){}; 106 } 107 108 public static void main(String[] args) { 109 Pos03<String> p3 = new Pos03<>(); 110 p3.testSimple(); 111 p3.testQualified_1(); 112 p3.testQualified_2(p3); 113 } 114} 115