test/tools/javac/generics/diamond/neg/Neg08.java

changeset 914
ca32f2986301
parent 537
9d9d08922405
child 2525
2eb010b6cb22
equal deleted inserted replaced
913:74f0c05c51eb 914:ca32f2986301
1 /* 1 /*
2 * @test /nodynamiccopyright/ 2 * @test /nodynamiccopyright/
3 * @bug 6939620 6894753 3 * @bug 7020043 7020044
4 * 4 *
5 * @summary Switch to 'complex' diamond inference scheme 5 * @summary Check that diamond is not allowed with non-generic class types
6 * @author mcimadamore 6 * @author Rémi Forax
7 * @compile/fail/ref=Neg08.out Neg08.java -XDrawDiagnostics 7 * @compile/fail/ref=Neg08.out Neg08.java -XDrawDiagnostics
8 * 8 *
9 */ 9 */
10 10
11 class Neg08 { 11 class Neg08 {
12 static class Foo<X> { 12 public static void main(String[] args) {
13 Foo(X x) { } 13 String s = new String<>("foo");
14 } 14 }
15
16 static class DoubleFoo<X,Y> {
17 DoubleFoo(X x,Y y) { }
18 }
19
20 static class TripleFoo<X,Y,Z> {
21 TripleFoo(X x,Y y,Z z) { }
22 }
23
24 Foo<? extends Integer> fi = new Foo<>(1);
25 Foo<?> fw = new Foo<>(fi);
26 Foo<? extends Double> fd = new Foo<>(3.0);
27 DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd);
28 Foo<String> fs = new Foo<>("one");
29 TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs);
30 } 15 }

mercurial