|
1 /* |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 6939620 7020044 |
|
4 * |
|
5 * @summary Check that diamond fails when inference violates declared bounds |
|
6 * (test with nested class, qualified/simple type expressions) |
|
7 * @author mcimadamore |
|
8 * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics |
|
9 * |
|
10 */ |
|
11 |
|
12 class Neg02 { |
|
13 |
|
14 static class Foo<X extends Number> { |
|
15 Foo(X x) {} |
|
16 <Z> Foo(X x, Z z) {} |
|
17 } |
|
18 |
|
19 void testSimple() { |
|
20 Foo<String> f1 = new Foo<>(""); |
|
21 Foo<? extends String> f2 = new Foo<>(""); |
|
22 Foo<?> f3 = new Foo<>(""); |
|
23 Foo<? super String> f4 = new Foo<>(""); |
|
24 |
|
25 Foo<String> f5 = new Foo<>("", ""); |
|
26 Foo<? extends String> f6 = new Foo<>("", ""); |
|
27 Foo<?> f7 = new Foo<>("", ""); |
|
28 Foo<? super String> f8 = new Foo<>("", ""); |
|
29 } |
|
30 |
|
31 void testQualified() { |
|
32 Foo<String> f1 = new Neg02.Foo<>(""); |
|
33 Foo<? extends String> f2 = new Neg02.Foo<>(""); |
|
34 Foo<?> f3 = new Neg02.Foo<>(""); |
|
35 Foo<? super String> f4 = new Neg02.Foo<>(""); |
|
36 |
|
37 Foo<String> f5 = new Neg02.Foo<>("", ""); |
|
38 Foo<? extends String> f6 = new Neg02.Foo<>("", ""); |
|
39 Foo<?> f7 = new Neg02.Foo<>("", ""); |
|
40 Foo<? super String> f8 = new Neg02.Foo<>("", ""); |
|
41 } |
|
42 } |