changeset 295:a9c04a57a39f

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
author mcimadamore
date Tue, 16 Jun 2009 10:45:11 +0100
parents 163f5d75f77a
children 3d539f4123b8
files src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java test/tools/javac/Diagnostics/6799605/T6799605.java test/tools/javac/Diagnostics/6799605/T6799605.out
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Thu Jun 11 21:35:12 2009 -0700
+++ b/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/test/tools/javac/Diagnostics/6799605/T6799605.java	Thu Jun 11 21:35:12 2009 -0700
+++ b/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/test/tools/javac/Diagnostics/6799605/T6799605.out	Thu Jun 11 21:35:12 2009 -0700
+++ b/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