214 return lb.toList();
215 }
216
217 /**For ErrorType, returns the original type, otherwise returns the type itself.
218 */
219 public Type getOriginalType() {
220 return this;
221 }
222
223 public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
224
225 /** Define a type given its tag, type symbol, and type annotations
226 */
227
228 public Type(TypeSymbol tsym, List<TypeMetadata> metadata) {
229 Assert.checkNonNull(metadata);
230 this.tsym = tsym;
231 this.metadata = metadata;
232 }
233
234 /**
235 * A subclass of {@link Types.TypeMapping} which applies a mapping recursively to the subterms
236 * of a given type expression. This mapping returns the original type is no changes occurred
237 * when recursively mapping the original type's subterms.
238 */
239 public abstract static class StructuralTypeMapping<S> extends Types.TypeMapping<S> {
240
241 @Override
242 public Type visitClassType(ClassType t, S s) {
243 Type outer = t.getEnclosingType();
244 Type outer1 = visit(outer, s);
245 List<Type> typarams = t.getTypeArguments();
246 List<Type> typarams1 = visit(typarams, s);
247 if (outer1 == outer && typarams1 == typarams) return t;
248 else return new ClassType(outer1, typarams1, t.tsym, t.metadata) {
249 @Override
250 protected boolean needsStripping() {
251 return true;
252 }
253 };
1157 return allparams_field;
1158 }
1159
1160 public boolean isErroneous() {
1161 return
1162 getEnclosingType().isErroneous() ||
1163 isErroneous(getTypeArguments()) ||
1164 this != tsym.type && tsym.type.isErroneous();
1165 }
1166
1167 public boolean isParameterized() {
1168 return allparams().tail != null;
1169 // optimization, was: allparams().nonEmpty();
1170 }
1171
1172 @Override
1173 public boolean isReference() {
1174 return true;
1175 }
1176
1177 @Override
1178 public boolean isNullOrReference() {
1179 return true;
1180 }
1181
1182 /** A cache for the rank. */
1183 int rank_field = -1;
1184
1185 /** A class type is raw if it misses some
1186 * of its type parameter sections.
1187 * After validation, this is equivalent to:
1188 * {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); }
1189 */
1190 public boolean isRaw() {
1191 return
1192 this != tsym.type && // necessary, but not sufficient condition
1193 tsym.type.allparams().nonEmpty() &&
1194 allparams().isEmpty();
1195 }
1196
2316 @Override
2317 public boolean isNullOrReference() {
2318 return true;
2319 }
2320
2321 }
2322
2323 public static class ErrorType extends ClassType
2324 implements javax.lang.model.type.ErrorType {
2325
2326 private Type originalType = null;
2327
2328 public ErrorType(ClassSymbol c, Type originalType) {
2329 this(originalType, c);
2330 c.type = this;
2331 c.kind = ERR;
2332 c.members_field = new Scope.ErrorScope(c);
2333 }
2334
2335 public ErrorType(Type originalType, TypeSymbol tsym) {
2336 super(noType, List.nil(), null);
2337 this.tsym = tsym;
2338 this.originalType = (originalType == null ? noType : originalType);
2339 }
2340
2341 public ErrorType(Type originalType, TypeSymbol tsym,
2342 List<TypeMetadata> metadata) {
2343 super(noType, List.nil(), null, metadata);
2344 this.tsym = tsym;
2345 this.originalType = (originalType == null ? noType : originalType);
2346 }
2347
2348 @Override
2349 protected ErrorType cloneWithMetadata(List<TypeMetadata> md) {
2350 return new ErrorType(originalType, tsym, md) {
2351 @Override
2352 public Type baseType() { return ErrorType.this.baseType(); }
2353 };
2354 }
2355
2356 @Override
2357 public TypeTag getTag() {
|
214 return lb.toList();
215 }
216
217 /**For ErrorType, returns the original type, otherwise returns the type itself.
218 */
219 public Type getOriginalType() {
220 return this;
221 }
222
223 public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
224
225 /** Define a type given its tag, type symbol, and type annotations
226 */
227
228 public Type(TypeSymbol tsym, List<TypeMetadata> metadata) {
229 Assert.checkNonNull(metadata);
230 this.tsym = tsym;
231 this.metadata = metadata;
232 }
233
234 public boolean isValueClass() {
235 return false;
236 }
237
238 public boolean isIdentityClass() {
239 return false;
240 }
241
242 // Does this type need to be preloaded in the context of the referring class ??
243 public boolean requiresLoadableDescriptors(Symbol referringClass) {
244 if (this.tsym == referringClass)
245 return false; // pointless
246 return this.isValueClass() && this.isFinal();
247 }
248
249 /**
250 * A subclass of {@link Types.TypeMapping} which applies a mapping recursively to the subterms
251 * of a given type expression. This mapping returns the original type is no changes occurred
252 * when recursively mapping the original type's subterms.
253 */
254 public abstract static class StructuralTypeMapping<S> extends Types.TypeMapping<S> {
255
256 @Override
257 public Type visitClassType(ClassType t, S s) {
258 Type outer = t.getEnclosingType();
259 Type outer1 = visit(outer, s);
260 List<Type> typarams = t.getTypeArguments();
261 List<Type> typarams1 = visit(typarams, s);
262 if (outer1 == outer && typarams1 == typarams) return t;
263 else return new ClassType(outer1, typarams1, t.tsym, t.metadata) {
264 @Override
265 protected boolean needsStripping() {
266 return true;
267 }
268 };
1172 return allparams_field;
1173 }
1174
1175 public boolean isErroneous() {
1176 return
1177 getEnclosingType().isErroneous() ||
1178 isErroneous(getTypeArguments()) ||
1179 this != tsym.type && tsym.type.isErroneous();
1180 }
1181
1182 public boolean isParameterized() {
1183 return allparams().tail != null;
1184 // optimization, was: allparams().nonEmpty();
1185 }
1186
1187 @Override
1188 public boolean isReference() {
1189 return true;
1190 }
1191
1192 @Override
1193 public boolean isValueClass() {
1194 return tsym != null && tsym.isValueClass();
1195 }
1196
1197 @Override
1198 public boolean isIdentityClass() {
1199 return tsym != null && tsym.isIdentityClass();
1200 }
1201
1202 @Override
1203 public boolean isNullOrReference() {
1204 return true;
1205 }
1206
1207 /** A cache for the rank. */
1208 int rank_field = -1;
1209
1210 /** A class type is raw if it misses some
1211 * of its type parameter sections.
1212 * After validation, this is equivalent to:
1213 * {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); }
1214 */
1215 public boolean isRaw() {
1216 return
1217 this != tsym.type && // necessary, but not sufficient condition
1218 tsym.type.allparams().nonEmpty() &&
1219 allparams().isEmpty();
1220 }
1221
2341 @Override
2342 public boolean isNullOrReference() {
2343 return true;
2344 }
2345
2346 }
2347
2348 public static class ErrorType extends ClassType
2349 implements javax.lang.model.type.ErrorType {
2350
2351 private Type originalType = null;
2352
2353 public ErrorType(ClassSymbol c, Type originalType) {
2354 this(originalType, c);
2355 c.type = this;
2356 c.kind = ERR;
2357 c.members_field = new Scope.ErrorScope(c);
2358 }
2359
2360 public ErrorType(Type originalType, TypeSymbol tsym) {
2361 super(noType, List.nil(), tsym, List.nil());
2362 this.originalType = (originalType == null ? noType : originalType);
2363 }
2364
2365 public ErrorType(Type originalType, TypeSymbol tsym,
2366 List<TypeMetadata> metadata) {
2367 super(noType, List.nil(), null, metadata);
2368 this.tsym = tsym;
2369 this.originalType = (originalType == null ? noType : originalType);
2370 }
2371
2372 @Override
2373 protected ErrorType cloneWithMetadata(List<TypeMetadata> md) {
2374 return new ErrorType(originalType, tsym, md) {
2375 @Override
2376 public Type baseType() { return ErrorType.this.baseType(); }
2377 };
2378 }
2379
2380 @Override
2381 public TypeTag getTag() {
|