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 6911256 6964740 |
aoqi@0 | 4 | * @author Joseph D. Darcy |
aoqi@0 | 5 | * @summary Verify bad TWRs don't compile |
aoqi@0 | 6 | * @compile/fail -source 6 TwrFlow.java |
aoqi@0 | 7 | * @compile/fail/ref=BadTwr.out -XDrawDiagnostics BadTwr.java |
aoqi@0 | 8 | */ |
aoqi@0 | 9 | |
aoqi@0 | 10 | public class BadTwr implements AutoCloseable { |
aoqi@0 | 11 | public static void main(String... args) { |
aoqi@0 | 12 | // illegal repeated name |
aoqi@0 | 13 | try(BadTwr r1 = new BadTwr(); BadTwr r1 = new BadTwr()) { |
aoqi@0 | 14 | System.out.println(r1.toString()); |
aoqi@0 | 15 | } |
aoqi@0 | 16 | |
aoqi@0 | 17 | // illegal duplicate name of method argument |
aoqi@0 | 18 | try(BadTwr args = new BadTwr()) { |
aoqi@0 | 19 | System.out.println(args.toString()); |
aoqi@0 | 20 | final BadTwr thatsIt = new BadTwr(); |
aoqi@0 | 21 | thatsIt = null; |
aoqi@0 | 22 | } |
aoqi@0 | 23 | |
aoqi@0 | 24 | try(BadTwr name = new BadTwr()) { |
aoqi@0 | 25 | // illegal duplicate name of enclosing try |
aoqi@0 | 26 | try(BadTwr name = new BadTwr()) { |
aoqi@0 | 27 | System.out.println(name.toString()); |
aoqi@0 | 28 | } |
aoqi@0 | 29 | } |
aoqi@0 | 30 | |
aoqi@0 | 31 | } |
aoqi@0 | 32 | |
aoqi@0 | 33 | public void close() { |
aoqi@0 | 34 | ; |
aoqi@0 | 35 | } |
aoqi@0 | 36 | } |