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