author | sadayapalam |
Thu, 26 Nov 2015 17:38:15 +0530 | |
changeset 34474 | 14deea5f86f1 |
parent 29776 | 984a79b71cfe |
permissions | -rw-r--r-- |
29776
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
1 |
/* |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
3 |
* @bug 8062373 |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
4 |
* |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
5 |
* @summary Test diamond + anonymous classes with abstract super type |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
6 |
* @author sadayapalam |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
7 |
* @compile/fail/ref=Neg13.out Neg13.java -XDrawDiagnostics |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
8 |
* |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
9 |
*/ |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
10 |
class Neg13 { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
11 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
12 |
static abstract class A<T> { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
13 |
abstract void foo(); |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
14 |
} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
15 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
16 |
static void foo(A<String> as) {} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
17 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
18 |
public static void main(String[] args) { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
19 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
20 |
// Method invocation context - good <>(){} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
21 |
foo(new A<>() { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
22 |
public void foo() {} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
23 |
}); |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
24 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
25 |
// Assignment context - good <>(){} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
26 |
A<?> aq = new A<>() { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
27 |
public void foo() {} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
28 |
}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
29 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
30 |
// When the anonymous type subtypes an abstract class but is missing definitions for |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
31 |
// abstract methods, expect no overload resolution error, but an attribution error |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
32 |
// while attributing anonymous class body. |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
33 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
34 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
35 |
// Method invocation context - bad <>(){} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
36 |
foo(new A<>() { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
37 |
}); |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
38 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
39 |
// Assignment invocation context - bad <>(){} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
40 |
aq = new A<>() { |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
41 |
}; |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
42 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
43 |
// Method invocation context - bad <>() |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
44 |
foo(new A<>()); |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
45 |
|
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
46 |
// Assignment invocation context - bad <>() |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
47 |
aq = new A<>(); |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
48 |
} |
984a79b71cfe
8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff
changeset
|
49 |
} |