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
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 4880220 |
aoqi@0 | 4 | * @summary Add a warning when accessing a static method via an reference |
aoqi@0 | 5 | * |
aoqi@0 | 6 | * @compile/ref=T4880220.empty.out T4880220.java |
aoqi@0 | 7 | * @compile/ref=T4880220.warn.out -XDrawDiagnostics -Xlint:static T4880220.java |
aoqi@0 | 8 | * @compile/ref=T4880220.warn.out -XDrawDiagnostics -Xlint:all T4880220.java |
aoqi@0 | 9 | * @compile/ref=T4880220.empty.out -XDrawDiagnostics -Xlint:all,-static T4880220.java |
aoqi@0 | 10 | * @compile/ref=T4880220.error.out/fail -XDrawDiagnostics -Werror -Xlint:all T4880220.java |
aoqi@0 | 11 | */ |
aoqi@0 | 12 | |
aoqi@0 | 13 | public class T4880220 { |
aoqi@0 | 14 | void m1() { |
aoqi@0 | 15 | int good_1 = C.m(); |
aoqi@0 | 16 | int good_2 = C.f; |
aoqi@0 | 17 | int good_3 = C.x; |
aoqi@0 | 18 | |
aoqi@0 | 19 | C c = new C(); |
aoqi@0 | 20 | int bad_inst_1 = c.m(); |
aoqi@0 | 21 | int bad_inst_2 = c.f; |
aoqi@0 | 22 | int bad_inst_3 = c.x; |
aoqi@0 | 23 | |
aoqi@0 | 24 | int bad_expr_1 = c().m(); |
aoqi@0 | 25 | int bad_expr_2 = c().f; |
aoqi@0 | 26 | int bad_expr_3 = c().x; |
aoqi@0 | 27 | } |
aoqi@0 | 28 | |
aoqi@0 | 29 | void m2() { |
aoqi@0 | 30 | Class<?> good_1 = C.class; |
aoqi@0 | 31 | Class<?> good_2 = C[].class; |
aoqi@0 | 32 | } |
aoqi@0 | 33 | |
aoqi@0 | 34 | C c() { |
aoqi@0 | 35 | return new C(); |
aoqi@0 | 36 | } |
aoqi@0 | 37 | |
aoqi@0 | 38 | static class C { |
aoqi@0 | 39 | static int m() { return 0; } |
aoqi@0 | 40 | static int f; |
aoqi@0 | 41 | static final int x = 3; |
aoqi@0 | 42 | } |
aoqi@0 | 43 | } |