Tue, 16 Jun 2009 10:45:11 +0100
6845686: basic and raw formatters do not display captured var id properly when javac runs in -XDoldDiags mode
Summary: Basic and raw formatters do not override Printer methods properly
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Thu Jun 11 21:35:12 2009 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Tue Jun 16 10:45:11 2009 +0100 1.3 @@ -172,9 +172,6 @@ 1.4 return formatIterable(d, (Iterable<?>)arg, l); 1.5 } 1.6 else if (arg instanceof Type) { 1.7 - if (!allCaptured.contains(arg)) { 1.8 - allCaptured = allCaptured.append((Type)arg); 1.9 - } 1.10 return printer.visit((Type)arg, l); 1.11 } 1.12 else if (arg instanceof Symbol) { 1.13 @@ -482,5 +479,12 @@ 1.14 protected String capturedVarId(CapturedType t, Locale locale) { 1.15 return "" + (allCaptured.indexOf(t) + 1); 1.16 } 1.17 + @Override 1.18 + public String visitCapturedType(CapturedType t, Locale locale) { 1.19 + if (!allCaptured.contains(t)) { 1.20 + allCaptured = allCaptured.append(t); 1.21 + } 1.22 + return super.visitCapturedType(t, locale); 1.23 + } 1.24 }; 1.25 }
2.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.java Thu Jun 11 21:35:12 2009 -0700 2.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.java Tue Jun 16 10:45:11 2009 +0100 2.3 @@ -27,6 +27,7 @@ 2.4 * @summary Basic/Raw formatters should use type/symbol printer instead of toString() 2.5 * @author mcimadamore 2.6 * @compile/fail/ref=T6799605.out -XDrawDiagnostics T6799605.java 2.7 + * @compile/fail/ref=T6799605.out -XDoldDiags -XDrawDiagnostics T6799605.java 2.8 */ 2.9 2.10 class T6799605<X> {
3.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.out Thu Jun 11 21:35:12 2009 -0700 3.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.out Tue Jun 16 10:45:11 2009 +0100 3.3 @@ -1,4 +1,4 @@ 3.4 -T6799605.java:39:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X> 3.5 -T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X> 3.6 -T6799605.java:41:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X> 3.7 +T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X> 3.8 +T6799605.java:41:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X> 3.9 +T6799605.java:42:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X> 3.10 3 errors