equal
deleted
inserted
replaced
|
1 /* |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 8008540 8008539 8008538 |
|
4 * @summary Constructor reference to non-reifiable array should be rejected |
|
5 * @compile/fail/ref=MethodReference64.out -XDrawDiagnostics MethodReference64.java |
|
6 */ |
|
7 class MethodReference64 { |
|
8 interface ClassFactory { |
|
9 Object m(); |
|
10 } |
|
11 |
|
12 interface ArrayFactory { |
|
13 Object m(int i); |
|
14 } |
|
15 |
|
16 @interface Anno { } |
|
17 |
|
18 enum E { } |
|
19 |
|
20 interface I { } |
|
21 |
|
22 static class Foo<X> { } |
|
23 |
|
24 void m(ClassFactory cf) { } |
|
25 void m(ArrayFactory cf) { } |
|
26 |
|
27 void testAssign() { |
|
28 ClassFactory c1 = Anno::new; //error |
|
29 ClassFactory c2 = E::new; //error |
|
30 ClassFactory c3 = I::new; //error |
|
31 ClassFactory c4 = Foo<?>::new; //error |
|
32 ClassFactory c5 = 1::new; //error |
|
33 ArrayFactory a1 = Foo<?>[]::new; //ok |
|
34 ArrayFactory a2 = Foo<? extends String>[]::new; //error |
|
35 } |
|
36 |
|
37 void testMethod() { |
|
38 m(Anno::new); //error |
|
39 m(E::new); //error |
|
40 m(I::new); //error |
|
41 m(Foo<?>::new); //error |
|
42 m(1::new); //error |
|
43 m(Foo<?>[]::new); //ok - resolves to m(ArrayFactory) |
|
44 m(Foo<? extends String>[]::new); //error |
|
45 } |
|
46 } |