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
--- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Thu Jun 11 21:35:12 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Tue Jun 16 10:45:11 2009 +0100
@@ -172,9 +172,6 @@
return formatIterable(d, (Iterable<?>)arg, l);
}
else if (arg instanceof Type) {
- if (!allCaptured.contains(arg)) {
- allCaptured = allCaptured.append((Type)arg);
- }
return printer.visit((Type)arg, l);
}
else if (arg instanceof Symbol) {
@@ -482,5 +479,12 @@
protected String capturedVarId(CapturedType t, Locale locale) {
return "" + (allCaptured.indexOf(t) + 1);
}
+ @Override
+ public String visitCapturedType(CapturedType t, Locale locale) {
+ if (!allCaptured.contains(t)) {
+ allCaptured = allCaptured.append(t);
+ }
+ return super.visitCapturedType(t, locale);
+ }
};
}
--- a/langtools/test/tools/javac/Diagnostics/6799605/T6799605.java Thu Jun 11 21:35:12 2009 -0700
+++ b/langtools/test/tools/javac/Diagnostics/6799605/T6799605.java Tue Jun 16 10:45:11 2009 +0100
@@ -27,6 +27,7 @@
* @summary Basic/Raw formatters should use type/symbol printer instead of toString()
* @author mcimadamore
* @compile/fail/ref=T6799605.out -XDrawDiagnostics T6799605.java
+ * @compile/fail/ref=T6799605.out -XDoldDiags -XDrawDiagnostics T6799605.java
*/
class T6799605<X> {
--- a/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out Thu Jun 11 21:35:12 2009 -0700
+++ b/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out Tue Jun 16 10:45:11 2009 +0100
@@ -1,4 +1,4 @@
-T6799605.java:39:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X>
-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>
-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>
+T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X>
+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>
+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 errors