221 * If this is a constant type, return its underlying type. |
221 * If this is a constant type, return its underlying type. |
222 * Otherwise, return the type itself. |
222 * Otherwise, return the type itself. |
223 */ |
223 */ |
224 public Type baseType() { |
224 public Type baseType() { |
225 return this; |
225 return this; |
|
226 } |
|
227 |
|
228 public Type annotatedType(List<Attribute.TypeCompound> annos) { |
|
229 return new AnnotatedType(annos, this); |
226 } |
230 } |
227 |
231 |
228 public boolean isAnnotated() { |
232 public boolean isAnnotated() { |
229 return false; |
233 return false; |
230 } |
234 } |
1816 javax.lang.model.type.PrimitiveType, |
1820 javax.lang.model.type.PrimitiveType, |
1817 javax.lang.model.type.TypeVariable, |
1821 javax.lang.model.type.TypeVariable, |
1818 javax.lang.model.type.WildcardType { |
1822 javax.lang.model.type.WildcardType { |
1819 /** The type annotations on this type. |
1823 /** The type annotations on this type. |
1820 */ |
1824 */ |
1821 public List<Attribute.TypeCompound> typeAnnotations; |
1825 private List<Attribute.TypeCompound> typeAnnotations; |
1822 |
1826 |
1823 /** The underlying type that is annotated. |
1827 /** The underlying type that is annotated. |
1824 */ |
1828 */ |
1825 public Type underlyingType; |
1829 private Type underlyingType; |
1826 |
1830 |
1827 public AnnotatedType(Type underlyingType) { |
1831 protected AnnotatedType(List<Attribute.TypeCompound> typeAnnotations, |
1828 super(underlyingType.tsym); |
|
1829 this.typeAnnotations = List.nil(); |
|
1830 this.underlyingType = underlyingType; |
|
1831 Assert.check(!underlyingType.isAnnotated(), |
|
1832 "Can't annotate already annotated type: " + underlyingType); |
|
1833 } |
|
1834 |
|
1835 public AnnotatedType(List<Attribute.TypeCompound> typeAnnotations, |
|
1836 Type underlyingType) { |
1832 Type underlyingType) { |
1837 super(underlyingType.tsym); |
1833 super(underlyingType.tsym); |
1838 this.typeAnnotations = typeAnnotations; |
1834 this.typeAnnotations = typeAnnotations; |
1839 this.underlyingType = underlyingType; |
1835 this.underlyingType = underlyingType; |
|
1836 Assert.check(typeAnnotations != null && typeAnnotations.nonEmpty(), |
|
1837 "Can't create AnnotatedType without annotations: " + underlyingType); |
1840 Assert.check(!underlyingType.isAnnotated(), |
1838 Assert.check(!underlyingType.isAnnotated(), |
1841 "Can't annotate already annotated type: " + underlyingType + |
1839 "Can't annotate already annotated type: " + underlyingType + |
1842 "; adding: " + typeAnnotations); |
1840 "; adding: " + typeAnnotations); |
1843 } |
1841 } |
1844 |
1842 |
1975 |
1973 |
1976 @Override |
1974 @Override |
1977 public TypeMirror getComponentType() { return ((ArrayType)underlyingType).getComponentType(); } |
1975 public TypeMirror getComponentType() { return ((ArrayType)underlyingType).getComponentType(); } |
1978 |
1976 |
1979 // The result is an ArrayType, but only in the model sense, not the Type sense. |
1977 // The result is an ArrayType, but only in the model sense, not the Type sense. |
1980 public AnnotatedType makeVarargs() { |
1978 public Type makeVarargs() { |
1981 AnnotatedType atype = new AnnotatedType(((ArrayType)underlyingType).makeVarargs()); |
1979 return ((ArrayType) underlyingType).makeVarargs().annotatedType(typeAnnotations); |
1982 atype.typeAnnotations = this.typeAnnotations; |
|
1983 return atype; |
|
1984 } |
1980 } |
1985 |
1981 |
1986 @Override |
1982 @Override |
1987 public TypeMirror getExtendsBound() { return ((WildcardType)underlyingType).getExtendsBound(); } |
1983 public TypeMirror getExtendsBound() { return ((WildcardType)underlyingType).getExtendsBound(); } |
1988 @Override |
1984 @Override |