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
2314 @Override
2315 public boolean isNullOrReference() {
2316 return true;
2317 }
2318
2319 }
2320
2321 public static class ErrorType extends ClassType
2322 implements javax.lang.model.type.ErrorType {
2323
2324 private Type originalType = null;
2325
2326 public ErrorType(ClassSymbol c, Type originalType) {
2327 this(originalType, c);
2328 c.type = this;
2329 c.kind = ERR;
2330 c.members_field = new Scope.ErrorScope(c);
2331 }
2332
2333 public ErrorType(Type originalType, TypeSymbol tsym) {
2334 super(noType, List.nil(), null);
2335 this.tsym = tsym;
2336 this.originalType = (originalType == null ? noType : originalType);
2337 }
2338
2339 public ErrorType(Type originalType, TypeSymbol tsym,
2340 List<TypeMetadata> metadata) {
2341 super(noType, List.nil(), null, metadata);
2342 this.tsym = tsym;
2343 this.originalType = (originalType == null ? noType : originalType);
2344 }
2345
2346 @Override
2347 protected ErrorType cloneWithMetadata(List<TypeMetadata> md) {
2348 return new ErrorType(originalType, tsym, md) {
2349 @Override
2350 public Type baseType() { return ErrorType.this.baseType(); }
2351 };
2352 }
2353
2354 @Override
2355 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
2339 @Override
2340 public boolean isNullOrReference() {
2341 return true;
2342 }
2343
2344 }
2345
2346 public static class ErrorType extends ClassType
2347 implements javax.lang.model.type.ErrorType {
2348
2349 private Type originalType = null;
2350
2351 public ErrorType(ClassSymbol c, Type originalType) {
2352 this(originalType, c);
2353 c.type = this;
2354 c.kind = ERR;
2355 c.members_field = new Scope.ErrorScope(c);
2356 }
2357
2358 public ErrorType(Type originalType, TypeSymbol tsym) {
2359 super(noType, List.nil(), tsym, List.nil());
2360 this.originalType = (originalType == null ? noType : originalType);
2361 }
2362
2363 public ErrorType(Type originalType, TypeSymbol tsym,
2364 List<TypeMetadata> metadata) {
2365 super(noType, List.nil(), null, metadata);
2366 this.tsym = tsym;
2367 this.originalType = (originalType == null ? noType : originalType);
2368 }
2369
2370 @Override
2371 protected ErrorType cloneWithMetadata(List<TypeMetadata> md) {
2372 return new ErrorType(originalType, tsym, md) {
2373 @Override
2374 public Type baseType() { return ErrorType.this.baseType(); }
2375 };
2376 }
2377
2378 @Override
2379 public TypeTag getTag() {
|