23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.code; |
26 package com.sun.tools.javac.code; |
27 |
27 |
28 import com.sun.tools.javac.model.JavacAnnoConstructs; |
|
29 import com.sun.tools.javac.model.JavacTypes; |
|
30 import java.lang.annotation.Annotation; |
28 import java.lang.annotation.Annotation; |
31 import java.util.Collections; |
29 import java.util.Collections; |
32 import java.util.EnumMap; |
30 import java.util.EnumMap; |
33 import java.util.EnumSet; |
31 import java.util.EnumSet; |
34 import java.util.Map; |
32 import java.util.Map; |
35 import java.util.Set; |
33 import java.util.Set; |
36 |
34 |
37 import javax.lang.model.element.AnnotationMirror; |
|
38 import javax.lang.model.type.*; |
35 import javax.lang.model.type.*; |
39 |
36 |
40 import com.sun.tools.javac.code.Symbol.*; |
37 import com.sun.tools.javac.code.Symbol.*; |
|
38 import com.sun.tools.javac.model.JavacAnnoConstructs; |
41 import com.sun.tools.javac.util.*; |
39 import com.sun.tools.javac.util.*; |
42 import static com.sun.tools.javac.code.BoundKind.*; |
40 import static com.sun.tools.javac.code.BoundKind.*; |
43 import static com.sun.tools.javac.code.Flags.*; |
41 import static com.sun.tools.javac.code.Flags.*; |
44 import static com.sun.tools.javac.code.Kinds.*; |
42 import static com.sun.tools.javac.code.Kinds.*; |
45 import static com.sun.tools.javac.code.TypeTag.*; |
43 import static com.sun.tools.javac.code.TypeTag.*; |
727 s.append(is.head.toString()); |
725 s.append(is.head.toString()); |
728 } |
726 } |
729 return s.toString(); |
727 return s.toString(); |
730 } else if (sym.name.isEmpty()) { |
728 } else if (sym.name.isEmpty()) { |
731 String s; |
729 String s; |
732 ClassType norm = (ClassType) tsym.type; |
730 ClassType norm = (ClassType) tsym.type.unannotatedType(); |
733 if (norm == null) { |
731 if (norm == null) { |
734 s = Log.getLocalizedString("anonymous.class", (Object)null); |
732 s = Log.getLocalizedString("anonymous.class", (Object)null); |
735 } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { |
733 } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { |
736 s = Log.getLocalizedString("anonymous.class", |
734 s = Log.getLocalizedString("anonymous.class", |
737 norm.interfaces_field.head); |
735 norm.interfaces_field.head); |
779 |
777 |
780 public boolean isErroneous() { |
778 public boolean isErroneous() { |
781 return |
779 return |
782 getEnclosingType().isErroneous() || |
780 getEnclosingType().isErroneous() || |
783 isErroneous(getTypeArguments()) || |
781 isErroneous(getTypeArguments()) || |
784 this != tsym.type && tsym.type.isErroneous(); |
782 this != tsym.type.unannotatedType() && tsym.type.isErroneous(); |
785 } |
783 } |
786 |
784 |
787 public boolean isParameterized() { |
785 public boolean isParameterized() { |
788 return allparams().tail != null; |
786 return allparams().tail != null; |
789 // optimization, was: allparams().nonEmpty(); |
787 // optimization, was: allparams().nonEmpty(); |
1691 @Override |
1689 @Override |
1692 public boolean isUnbound() { return underlyingType.isUnbound(); } |
1690 public boolean isUnbound() { return underlyingType.isUnbound(); } |
1693 |
1691 |
1694 @Override |
1692 @Override |
1695 public String toString() { |
1693 public String toString() { |
1696 // TODO more logic for arrays, etc. |
1694 // This method is only used for internal debugging output. |
|
1695 // See |
|
1696 // com.sun.tools.javac.code.Printer.visitAnnotatedType(AnnotatedType, Locale) |
|
1697 // for the user-visible logic. |
1697 if (typeAnnotations != null && |
1698 if (typeAnnotations != null && |
1698 !typeAnnotations.isEmpty()) { |
1699 !typeAnnotations.isEmpty()) { |
1699 return "(" + typeAnnotations.toString() + " :: " + underlyingType.toString() + ")"; |
1700 return "(" + typeAnnotations.toString() + " :: " + underlyingType.toString() + ")"; |
1700 } else { |
1701 } else { |
1701 return "({} :: " + underlyingType.toString() +")"; |
1702 return "({} :: " + underlyingType.toString() +")"; |
1703 } |
1704 } |
1704 |
1705 |
1705 @Override |
1706 @Override |
1706 public boolean contains(Type t) { return underlyingType.contains(t); } |
1707 public boolean contains(Type t) { return underlyingType.contains(t); } |
1707 |
1708 |
1708 // TODO: attach annotations? |
1709 @Override |
1709 @Override |
1710 public Type withTypeVar(Type t) { |
1710 public Type withTypeVar(Type t) { return underlyingType.withTypeVar(t); } |
1711 // Don't create a new AnnotatedType, as 'this' will |
|
1712 // get its annotations set later. |
|
1713 underlyingType = underlyingType.withTypeVar(t); |
|
1714 return this; |
|
1715 } |
1711 |
1716 |
1712 // TODO: attach annotations? |
1717 // TODO: attach annotations? |
1713 @Override |
1718 @Override |
1714 public TypeSymbol asElement() { return underlyingType.asElement(); } |
1719 public TypeSymbol asElement() { return underlyingType.asElement(); } |
1715 |
1720 |