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 };
1160 return allparams_field;
1161 }
1162
1163 public boolean isErroneous() {
1164 return
1165 getEnclosingType().isErroneous() ||
1166 isErroneous(getTypeArguments()) ||
1167 this != tsym.type && tsym.type.isErroneous();
1168 }
1169
1170 public boolean isParameterized() {
1171 return allparams().tail != null;
1172 // optimization, was: allparams().nonEmpty();
1173 }
1174
1175 @Override
1176 public boolean isReference() {
1177 return true;
1178 }
1179
1180 @Override
1181 public boolean isNullOrReference() {
1182 return true;
1183 }
1184
1185 /** A cache for the rank. */
1186 int rank_field = -1;
1187
1188 /** A class type is raw if it misses some
1189 * of its type parameter sections.
1190 * After validation, this is equivalent to:
1191 * {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); }
1192 */
1193 public boolean isRaw() {
1194 return
1195 this != tsym.type && // necessary, but not sufficient condition
1196 tsym.type.allparams().nonEmpty() &&
1197 allparams().isEmpty();
1198 }
1199
2318 @Override
2319 public boolean isNullOrReference() {
2320 return true;
2321 }
2322
2323 }
2324
2325 public static class ErrorType extends ClassType
2326 implements javax.lang.model.type.ErrorType {
2327
2328 private Type originalType = null;
2329
2330 public ErrorType(ClassSymbol c, Type originalType) {
2331 this(originalType, c);
2332 c.type = this;
2333 c.kind = ERR;
2334 c.members_field = new Scope.ErrorScope(c);
2335 }
2336
2337 public ErrorType(Type originalType, TypeSymbol tsym) {
2338 super(noType, List.nil(), null);
2339 this.tsym = tsym;
2340 this.originalType = (originalType == null ? noType : originalType);
2341 }
2342
2343 public ErrorType(Type originalType, TypeSymbol tsym,
2344 List<TypeMetadata> metadata) {
2345 super(noType, List.nil(), null, metadata);
2346 this.tsym = tsym;
2347 this.originalType = (originalType == null ? noType : originalType);
2348 }
2349
2350 @Override
2351 protected ErrorType cloneWithMetadata(List<TypeMetadata> md) {
2352 return new ErrorType(originalType, tsym, md) {
2353 @Override
2354 public Type baseType() { return ErrorType.this.baseType(); }
2355 };
2356 }
2357
2358 @Override
2359 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 };
1175 return allparams_field;
1176 }
1177
1178 public boolean isErroneous() {
1179 return
1180 getEnclosingType().isErroneous() ||
1181 isErroneous(getTypeArguments()) ||
1182 this != tsym.type && tsym.type.isErroneous();
1183 }
1184
1185 public boolean isParameterized() {
1186 return allparams().tail != null;
1187 // optimization, was: allparams().nonEmpty();
1188 }
1189
1190 @Override
1191 public boolean isReference() {
1192 return true;
1193 }
1194
1195 @Override
1196 public boolean isValueClass() {
1197 return tsym != null && tsym.isValueClass();
1198 }
1199
1200 @Override
1201 public boolean isIdentityClass() {
1202 return tsym != null && tsym.isIdentityClass();
1203 }
1204
1205 @Override
1206 public boolean isNullOrReference() {
1207 return true;
1208 }
1209
1210 /** A cache for the rank. */
1211 int rank_field = -1;
1212
1213 /** A class type is raw if it misses some
1214 * of its type parameter sections.
1215 * After validation, this is equivalent to:
1216 * {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); }
1217 */
1218 public boolean isRaw() {
1219 return
1220 this != tsym.type && // necessary, but not sufficient condition
1221 tsym.type.allparams().nonEmpty() &&
1222 allparams().isEmpty();
1223 }
1224
2343 @Override
2344 public boolean isNullOrReference() {
2345 return true;
2346 }
2347
2348 }
2349
2350 public static class ErrorType extends ClassType
2351 implements javax.lang.model.type.ErrorType {
2352
2353 private Type originalType = null;
2354
2355 public ErrorType(ClassSymbol c, Type originalType) {
2356 this(originalType, c);
2357 c.type = this;
2358 c.kind = ERR;
2359 c.members_field = new Scope.ErrorScope(c);
2360 }
2361
2362 public ErrorType(Type originalType, TypeSymbol tsym) {
2363 super(noType, List.nil(), tsym, List.nil());
2364 this.originalType = (originalType == null ? noType : originalType);
2365 }
2366
2367 public ErrorType(Type originalType, TypeSymbol tsym,
2368 List<TypeMetadata> metadata) {
2369 super(noType, List.nil(), null, metadata);
2370 this.tsym = tsym;
2371 this.originalType = (originalType == null ? noType : originalType);
2372 }
2373
2374 @Override
2375 protected ErrorType cloneWithMetadata(List<TypeMetadata> md) {
2376 return new ErrorType(originalType, tsym, md) {
2377 @Override
2378 public Type baseType() { return ErrorType.this.baseType(); }
2379 };
2380 }
2381
2382 @Override
2383 public TypeTag getTag() {
|