changeset 2332:af616ad22321

Document relationship between toString and Printer. Improve withTypeVar and correctly attach annotations.
author wmdietl
date Wed, 20 Mar 2013 14:51:10 +0100
parents 8dd36a9c5ed2
children e08f0bbe84f0
files src/share/classes/com/sun/tools/javac/code/Type.java
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 20 14:50:28 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 20 14:51:10 2013 +0100
@@ -1685,7 +1685,10 @@
 
         @Override
         public String toString() {
-            // TODO more logic for arrays, etc.
+            // This method is only used for internal debugging output.
+            // See
+            // com.sun.tools.javac.code.Printer.visitAnnotatedType(AnnotatedType, Locale)
+            // for the user-visible logic.
             if (typeAnnotations != null &&
                     !typeAnnotations.isEmpty()) {
                 return "(" + typeAnnotations.toString() + " :: " + underlyingType.toString() + ")";
@@ -1697,9 +1700,13 @@
         @Override
         public boolean contains(Type t)          { return underlyingType.contains(t); }
 
-        // TODO: attach annotations?
         @Override
-        public Type withTypeVar(Type t)          { return underlyingType.withTypeVar(t); }
+        public Type withTypeVar(Type t) {
+            // Don't create a new AnnotatedType, as 'this' will
+            // get its annotations set later.
+            underlyingType = underlyingType.withTypeVar(t);
+            return this;
+        }
 
         // TODO: attach annotations?
         @Override