Thu, 03 Feb 2011 09:36:28 +0000
5017953: spurious cascaded diagnostics when name not found
Summary: when an operator is applied to one or more erroneous operands, spurious diagnostics are generated
Reviewed-by: jjg
1 /**
2 * @test /nodynamiccopyright/
3 * @bug 4986256
4 * @compile/ref=Unchecked.noLint.out -XDrawDiagnostics Unchecked.java
5 * @compile/ref=Unchecked.lintUnchecked.out -Xlint:unchecked -XDrawDiagnostics Unchecked.java
6 * @compile/ref=Unchecked.lintAll.out -Xlint:all,-path -XDrawDiagnostics Unchecked.java
7 */
9 import java.util.ArrayList;
10 import java.util.List;
12 // control: this class should generate warnings
13 class Unchecked
14 {
15 void m() {
16 List l = new ArrayList<String>();
17 l.add("abc");
18 }
19 }
21 // tests: the warnings that would otherwise be generated should all be suppressed
22 @SuppressWarnings("unchecked")
23 class Unchecked2
24 {
25 void m() {
26 List l = new ArrayList<String>();
27 l.add("abc");
28 }
29 }
31 class Unchecked3
32 {
33 @SuppressWarnings("unchecked")
34 void m() {
35 List l = new ArrayList<String>();
36 l.add("abc");
37 }
38 }
40 class Unchecked4
41 {
42 void m() {
43 @SuppressWarnings("unchecked")
44 class Inner {
45 void m() {
46 List l = new ArrayList<String>();
47 l.add("abc");
48 }
49 }
50 }
51 }
53 // this class should produce warnings because @SuppressWarnings should not be inherited
54 class Unchecked5 extends Unchecked2
55 {
56 void m() {
57 List l = new ArrayList<String>();
58 l.add("abc");
59 }
60 }