34 |
34 |
35 import javax.lang.model.type.*; |
35 import javax.lang.model.type.*; |
36 |
36 |
37 import com.sun.tools.javac.code.Symbol.*; |
37 import com.sun.tools.javac.code.Symbol.*; |
38 import com.sun.tools.javac.util.*; |
38 import com.sun.tools.javac.util.*; |
|
39 import com.sun.tools.javac.util.DefinedBy.Api; |
39 import static com.sun.tools.javac.code.BoundKind.*; |
40 import static com.sun.tools.javac.code.BoundKind.*; |
40 import static com.sun.tools.javac.code.Flags.*; |
41 import static com.sun.tools.javac.code.Flags.*; |
41 import static com.sun.tools.javac.code.Kinds.*; |
42 import static com.sun.tools.javac.code.Kinds.*; |
42 import static com.sun.tools.javac.code.TypeTag.*; |
43 import static com.sun.tools.javac.code.TypeTag.*; |
43 |
44 |
71 */ |
72 */ |
72 public abstract class Type extends AnnoConstruct implements TypeMirror { |
73 public abstract class Type extends AnnoConstruct implements TypeMirror { |
73 |
74 |
74 /** Constant type: no type at all. */ |
75 /** Constant type: no type at all. */ |
75 public static final JCNoType noType = new JCNoType() { |
76 public static final JCNoType noType = new JCNoType() { |
76 @Override |
77 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
77 public String toString() { |
78 public String toString() { |
78 return "none"; |
79 return "none"; |
79 } |
80 } |
80 }; |
81 }; |
81 |
82 |
82 /** Constant type: special type to be used during recovery of deferred expressions. */ |
83 /** Constant type: special type to be used during recovery of deferred expressions. */ |
83 public static final JCNoType recoveryType = new JCNoType(){ |
84 public static final JCNoType recoveryType = new JCNoType(){ |
84 @Override |
85 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
85 public String toString() { |
86 public String toString() { |
86 return "recovery"; |
87 return "recovery"; |
87 } |
88 } |
88 }; |
89 }; |
89 |
90 |
90 /** Constant type: special type to be used for marking stuck trees. */ |
91 /** Constant type: special type to be used for marking stuck trees. */ |
91 public static final JCNoType stuckType = new JCNoType() { |
92 public static final JCNoType stuckType = new JCNoType() { |
92 @Override |
93 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
93 public String toString() { |
94 public String toString() { |
94 return "stuck"; |
95 return "stuck"; |
95 } |
96 } |
96 }; |
97 }; |
97 |
98 |
256 |
257 |
257 public boolean isAnnotated() { |
258 public boolean isAnnotated() { |
258 return !annos.isEmpty(); |
259 return !annos.isEmpty(); |
259 } |
260 } |
260 |
261 |
261 @Override |
262 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
262 public List<Attribute.TypeCompound> getAnnotationMirrors() { |
263 public List<Attribute.TypeCompound> getAnnotationMirrors() { |
263 return annos; |
264 return annos; |
264 } |
265 } |
265 |
266 |
266 |
267 |
267 @Override |
268 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
268 public <A extends Annotation> A getAnnotation(Class<A> annotationType) { |
269 public <A extends Annotation> A getAnnotation(Class<A> annotationType) { |
269 return null; |
270 return null; |
270 } |
271 } |
271 |
272 |
272 |
273 |
273 @Override |
274 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
274 public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) { |
275 public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) { |
275 @SuppressWarnings("unchecked") |
276 @SuppressWarnings("unchecked") |
276 A[] tmp = (A[]) java.lang.reflect.Array.newInstance(annotationType, 0); |
277 A[] tmp = (A[]) java.lang.reflect.Array.newInstance(annotationType, 0); |
277 return tmp; |
278 return tmp; |
278 } |
279 } |
304 appendAnnotationsString(sb, false); |
305 appendAnnotationsString(sb, false); |
305 } |
306 } |
306 |
307 |
307 /** The Java source which this type represents. |
308 /** The Java source which this type represents. |
308 */ |
309 */ |
|
310 @DefinedBy(Api.LANGUAGE_MODEL) |
309 public String toString() { |
311 public String toString() { |
310 StringBuilder sb = new StringBuilder(); |
312 StringBuilder sb = new StringBuilder(); |
311 appendAnnotationsString(sb); |
313 appendAnnotationsString(sb); |
312 if (tsym == null || tsym.name == null) { |
314 if (tsym == null || tsym.name == null) { |
313 sb.append("<none>"); |
315 sb.append("<none>"); |
348 /** |
350 /** |
349 * This method is analogous to isSameType, but weaker, since we |
351 * This method is analogous to isSameType, but weaker, since we |
350 * never complete classes. Where isSameType would complete a |
352 * never complete classes. Where isSameType would complete a |
351 * class, equals assumes that the two types are different. |
353 * class, equals assumes that the two types are different. |
352 */ |
354 */ |
353 @Override |
355 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
354 public boolean equals(Object t) { |
356 public boolean equals(Object t) { |
355 return super.equals(t); |
357 return super.equals(t); |
356 } |
358 } |
357 |
359 |
358 @Override |
360 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
359 public int hashCode() { |
361 public int hashCode() { |
360 return super.hashCode(); |
362 return super.hashCode(); |
361 } |
363 } |
362 |
364 |
363 public String argtypes(boolean varargs) { |
365 public String argtypes(boolean varargs) { |
504 |
506 |
505 public TypeSymbol asElement() { |
507 public TypeSymbol asElement() { |
506 return tsym; |
508 return tsym; |
507 } |
509 } |
508 |
510 |
509 @Override |
511 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
510 public TypeKind getKind() { |
512 public TypeKind getKind() { |
511 return TypeKind.OTHER; |
513 return TypeKind.OTHER; |
512 } |
514 } |
513 |
515 |
514 @Override |
516 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
515 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
517 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
516 throw new AssertionError(); |
518 throw new AssertionError(); |
517 } |
519 } |
518 |
520 |
519 public static class JCPrimitiveType extends Type |
521 public static class JCPrimitiveType extends Type |
610 tag == BOOLEAN && |
612 tag == BOOLEAN && |
611 constValue() != null && |
613 constValue() != null && |
612 ((Integer)constValue()).intValue() != 0; |
614 ((Integer)constValue()).intValue() != 0; |
613 } |
615 } |
614 |
616 |
615 @Override |
617 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
616 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
618 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
617 return v.visitPrimitive(this, p); |
619 return v.visitPrimitive(this, p); |
618 } |
620 } |
619 |
621 |
620 @Override |
622 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
621 public TypeKind getKind() { |
623 public TypeKind getKind() { |
622 switch (tag) { |
624 switch (tag) { |
623 case BYTE: return TypeKind.BYTE; |
625 case BYTE: return TypeKind.BYTE; |
624 case CHAR: return TypeKind.CHAR; |
626 case CHAR: return TypeKind.CHAR; |
625 case SHORT: return TypeKind.SHORT; |
627 case SHORT: return TypeKind.SHORT; |
718 bound = (TypeVar)t; |
720 bound = (TypeVar)t; |
719 return this; |
721 return this; |
720 } |
722 } |
721 |
723 |
722 boolean isPrintingBound = false; |
724 boolean isPrintingBound = false; |
|
725 @DefinedBy(Api.LANGUAGE_MODEL) |
723 public String toString() { |
726 public String toString() { |
724 StringBuilder s = new StringBuilder(); |
727 StringBuilder s = new StringBuilder(); |
725 appendAnnotationsString(s); |
728 appendAnnotationsString(s); |
726 s.append(kind.toString()); |
729 s.append(kind.toString()); |
727 if (kind != UNBOUND) |
730 if (kind != UNBOUND) |
745 return this; |
748 return this; |
746 else |
749 else |
747 return new WildcardType(t, kind, tsym, bound, annos); |
750 return new WildcardType(t, kind, tsym, bound, annos); |
748 } |
751 } |
749 |
752 |
|
753 @DefinedBy(Api.LANGUAGE_MODEL) |
750 public Type getExtendsBound() { |
754 public Type getExtendsBound() { |
751 if (kind == EXTENDS) |
755 if (kind == EXTENDS) |
752 return type; |
756 return type; |
753 else |
757 else |
754 return null; |
758 return null; |
755 } |
759 } |
756 |
760 |
|
761 @DefinedBy(Api.LANGUAGE_MODEL) |
757 public Type getSuperBound() { |
762 public Type getSuperBound() { |
758 if (kind == SUPER) |
763 if (kind == SUPER) |
759 return type; |
764 return type; |
760 else |
765 else |
761 return null; |
766 return null; |
762 } |
767 } |
763 |
768 |
|
769 @DefinedBy(Api.LANGUAGE_MODEL) |
764 public TypeKind getKind() { |
770 public TypeKind getKind() { |
765 return TypeKind.WILDCARD; |
771 return TypeKind.WILDCARD; |
766 } |
772 } |
767 |
773 |
|
774 @DefinedBy(Api.LANGUAGE_MODEL) |
768 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
775 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
769 return v.visitWildcard(this, p); |
776 return v.visitWildcard(this, p); |
770 } |
777 } |
771 } |
778 } |
772 |
779 |
856 }; |
863 }; |
857 } |
864 } |
858 |
865 |
859 /** The Java source which this type represents. |
866 /** The Java source which this type represents. |
860 */ |
867 */ |
|
868 @DefinedBy(Api.LANGUAGE_MODEL) |
861 public String toString() { |
869 public String toString() { |
862 StringBuilder buf = new StringBuilder(); |
870 StringBuilder buf = new StringBuilder(); |
863 appendAnnotationsString(buf); |
871 appendAnnotationsString(buf); |
864 if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) { |
872 if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) { |
865 buf.append(getEnclosingType().toString()); |
873 buf.append(getEnclosingType().toString()); |
904 } else { |
912 } else { |
905 return sym.name.toString(); |
913 return sym.name.toString(); |
906 } |
914 } |
907 } |
915 } |
908 |
916 |
|
917 @DefinedBy(Api.LANGUAGE_MODEL) |
909 public List<Type> getTypeArguments() { |
918 public List<Type> getTypeArguments() { |
910 if (typarams_field == null) { |
919 if (typarams_field == null) { |
911 complete(); |
920 complete(); |
912 if (typarams_field == null) |
921 if (typarams_field == null) |
913 typarams_field = List.nil(); |
922 typarams_field = List.nil(); |
991 |
1001 |
992 public void complete() { |
1002 public void complete() { |
993 if (tsym.completer != null) tsym.complete(); |
1003 if (tsym.completer != null) tsym.complete(); |
994 } |
1004 } |
995 |
1005 |
|
1006 @DefinedBy(Api.LANGUAGE_MODEL) |
996 public TypeKind getKind() { |
1007 public TypeKind getKind() { |
997 return TypeKind.DECLARED; |
1008 return TypeKind.DECLARED; |
998 } |
1009 } |
999 |
1010 |
|
1011 @DefinedBy(Api.LANGUAGE_MODEL) |
1000 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1012 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1001 return v.visitDeclared(this, p); |
1013 return v.visitDeclared(this, p); |
1002 } |
1014 } |
1003 } |
1015 } |
1004 |
1016 |
1035 |
1047 |
1036 public Type getLub() { |
1048 public Type getLub() { |
1037 return tsym.type; |
1049 return tsym.type; |
1038 } |
1050 } |
1039 |
1051 |
|
1052 @DefinedBy(Api.LANGUAGE_MODEL) |
1040 public java.util.List<? extends TypeMirror> getAlternatives() { |
1053 public java.util.List<? extends TypeMirror> getAlternatives() { |
1041 return Collections.unmodifiableList(alternatives_field); |
1054 return Collections.unmodifiableList(alternatives_field); |
1042 } |
1055 } |
1043 |
1056 |
1044 @Override |
1057 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1045 public TypeKind getKind() { |
1058 public TypeKind getKind() { |
1046 return TypeKind.UNION; |
1059 return TypeKind.UNION; |
1047 } |
1060 } |
1048 |
1061 |
1049 @Override |
1062 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1050 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1063 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1051 return v.visitUnion(this, p); |
1064 return v.visitUnion(this, p); |
1052 } |
1065 } |
1053 |
1066 |
1054 public Iterable<? extends Type> getAlternativeTypes() { |
1067 public Iterable<? extends Type> getAlternativeTypes() { |
1071 interfaces_field = bounds.tail; |
1084 interfaces_field = bounds.tail; |
1072 Assert.check(supertype_field.tsym.completer != null || |
1085 Assert.check(supertype_field.tsym.completer != null || |
1073 !supertype_field.isInterface(), supertype_field); |
1086 !supertype_field.isInterface(), supertype_field); |
1074 } |
1087 } |
1075 |
1088 |
|
1089 @DefinedBy(Api.LANGUAGE_MODEL) |
1076 public java.util.List<? extends TypeMirror> getBounds() { |
1090 public java.util.List<? extends TypeMirror> getBounds() { |
1077 return Collections.unmodifiableList(getExplicitComponents()); |
1091 return Collections.unmodifiableList(getExplicitComponents()); |
1078 } |
1092 } |
1079 |
1093 |
1080 public List<Type> getComponents() { |
1094 public List<Type> getComponents() { |
1085 return allInterfaces ? |
1099 return allInterfaces ? |
1086 interfaces_field : |
1100 interfaces_field : |
1087 getComponents(); |
1101 getComponents(); |
1088 } |
1102 } |
1089 |
1103 |
1090 @Override |
1104 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1091 public TypeKind getKind() { |
1105 public TypeKind getKind() { |
1092 return TypeKind.INTERSECTION; |
1106 return TypeKind.INTERSECTION; |
1093 } |
1107 } |
1094 |
1108 |
1095 @Override |
1109 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1096 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1110 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1097 return v.visitIntersection(this, p); |
1111 return v.visitIntersection(this, p); |
1098 } |
1112 } |
1099 } |
1113 } |
1100 |
1114 |
1125 |
1139 |
1126 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1140 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1127 return v.visitArrayType(this, s); |
1141 return v.visitArrayType(this, s); |
1128 } |
1142 } |
1129 |
1143 |
|
1144 @DefinedBy(Api.LANGUAGE_MODEL) |
1130 public String toString() { |
1145 public String toString() { |
1131 StringBuilder sb = new StringBuilder(); |
1146 StringBuilder sb = new StringBuilder(); |
1132 sb.append(elemtype); |
1147 sb.append(elemtype); |
1133 appendAnnotationsString(sb, true); |
1148 appendAnnotationsString(sb, true); |
1134 sb.append("[]"); |
1149 sb.append("[]"); |
1135 return sb.toString(); |
1150 return sb.toString(); |
1136 } |
1151 } |
1137 |
1152 |
|
1153 @DefinedBy(Api.LANGUAGE_MODEL) |
1138 public boolean equals(Object obj) { |
1154 public boolean equals(Object obj) { |
1139 return |
1155 return |
1140 this == obj || |
1156 this == obj || |
1141 (obj instanceof ArrayType && |
1157 (obj instanceof ArrayType && |
1142 this.elemtype.equals(((ArrayType)obj).elemtype)); |
1158 this.elemtype.equals(((ArrayType)obj).elemtype)); |
1143 } |
1159 } |
1144 |
1160 |
|
1161 @DefinedBy(Api.LANGUAGE_MODEL) |
1145 public int hashCode() { |
1162 public int hashCode() { |
1146 return (ARRAY.ordinal() << 5) + elemtype.hashCode(); |
1163 return (ARRAY.ordinal() << 5) + elemtype.hashCode(); |
1147 } |
1164 } |
1148 |
1165 |
1149 public boolean isVarargs() { |
1166 public boolean isVarargs() { |
1195 |
1212 |
1196 public void complete() { |
1213 public void complete() { |
1197 elemtype.complete(); |
1214 elemtype.complete(); |
1198 } |
1215 } |
1199 |
1216 |
|
1217 @DefinedBy(Api.LANGUAGE_MODEL) |
1200 public Type getComponentType() { |
1218 public Type getComponentType() { |
1201 return elemtype; |
1219 return elemtype; |
1202 } |
1220 } |
1203 |
1221 |
|
1222 @DefinedBy(Api.LANGUAGE_MODEL) |
1204 public TypeKind getKind() { |
1223 public TypeKind getKind() { |
1205 return TypeKind.ARRAY; |
1224 return TypeKind.ARRAY; |
1206 } |
1225 } |
1207 |
1226 |
|
1227 @DefinedBy(Api.LANGUAGE_MODEL) |
1208 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1228 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1209 return v.visitArray(this, p); |
1229 return v.visitArray(this, p); |
1210 } |
1230 } |
1211 } |
1231 } |
1212 |
1232 |
1249 /** The Java source which this type represents. |
1269 /** The Java source which this type represents. |
1250 * |
1270 * |
1251 * XXX 06/09/99 iris This isn't correct Java syntax, but it probably |
1271 * XXX 06/09/99 iris This isn't correct Java syntax, but it probably |
1252 * should be. |
1272 * should be. |
1253 */ |
1273 */ |
|
1274 @DefinedBy(Api.LANGUAGE_MODEL) |
1254 public String toString() { |
1275 public String toString() { |
1255 StringBuilder sb = new StringBuilder(); |
1276 StringBuilder sb = new StringBuilder(); |
1256 appendAnnotationsString(sb); |
1277 appendAnnotationsString(sb); |
1257 sb.append('('); |
1278 sb.append('('); |
1258 sb.append(argtypes); |
1279 sb.append(argtypes); |
1259 sb.append(')'); |
1280 sb.append(')'); |
1260 sb.append(restype); |
1281 sb.append(restype); |
1261 return sb.toString(); |
1282 return sb.toString(); |
1262 } |
1283 } |
1263 |
1284 |
|
1285 @DefinedBy(Api.LANGUAGE_MODEL) |
1264 public List<Type> getParameterTypes() { return argtypes; } |
1286 public List<Type> getParameterTypes() { return argtypes; } |
|
1287 @DefinedBy(Api.LANGUAGE_MODEL) |
1265 public Type getReturnType() { return restype; } |
1288 public Type getReturnType() { return restype; } |
|
1289 @DefinedBy(Api.LANGUAGE_MODEL) |
1266 public Type getReceiverType() { return recvtype; } |
1290 public Type getReceiverType() { return recvtype; } |
|
1291 @DefinedBy(Api.LANGUAGE_MODEL) |
1267 public List<Type> getThrownTypes() { return thrown; } |
1292 public List<Type> getThrownTypes() { return thrown; } |
1268 |
1293 |
1269 public boolean isErroneous() { |
1294 public boolean isErroneous() { |
1270 return |
1295 return |
1271 isErroneous(argtypes) || |
1296 isErroneous(argtypes) || |
1295 recvtype.complete(); |
1320 recvtype.complete(); |
1296 for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) |
1321 for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) |
1297 l.head.complete(); |
1322 l.head.complete(); |
1298 } |
1323 } |
1299 |
1324 |
|
1325 @DefinedBy(Api.LANGUAGE_MODEL) |
1300 public List<TypeVar> getTypeVariables() { |
1326 public List<TypeVar> getTypeVariables() { |
1301 return List.nil(); |
1327 return List.nil(); |
1302 } |
1328 } |
1303 |
1329 |
1304 public TypeSymbol asElement() { |
1330 public TypeSymbol asElement() { |
1305 return null; |
1331 return null; |
1306 } |
1332 } |
1307 |
1333 |
|
1334 @DefinedBy(Api.LANGUAGE_MODEL) |
1308 public TypeKind getKind() { |
1335 public TypeKind getKind() { |
1309 return TypeKind.EXECUTABLE; |
1336 return TypeKind.EXECUTABLE; |
1310 } |
1337 } |
1311 |
1338 |
|
1339 @DefinedBy(Api.LANGUAGE_MODEL) |
1312 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1340 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1313 return v.visitExecutable(this, p); |
1341 return v.visitExecutable(this, p); |
1314 } |
1342 } |
1315 } |
1343 } |
1316 |
1344 |
1334 @Override |
1362 @Override |
1335 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1363 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1336 return v.visitPackageType(this, s); |
1364 return v.visitPackageType(this, s); |
1337 } |
1365 } |
1338 |
1366 |
|
1367 @DefinedBy(Api.LANGUAGE_MODEL) |
1339 public String toString() { |
1368 public String toString() { |
1340 return tsym.getQualifiedName().toString(); |
1369 return tsym.getQualifiedName().toString(); |
1341 } |
1370 } |
1342 |
1371 |
|
1372 @DefinedBy(Api.LANGUAGE_MODEL) |
1343 public TypeKind getKind() { |
1373 public TypeKind getKind() { |
1344 return TypeKind.PACKAGE; |
1374 return TypeKind.PACKAGE; |
1345 } |
1375 } |
1346 |
1376 |
|
1377 @DefinedBy(Api.LANGUAGE_MODEL) |
1347 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1378 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1348 return v.visitNoType(this, p); |
1379 return v.visitNoType(this, p); |
1349 } |
1380 } |
1350 } |
1381 } |
1351 |
1382 |
1401 @Override |
1432 @Override |
1402 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1433 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1403 return v.visitTypeVar(this, s); |
1434 return v.visitTypeVar(this, s); |
1404 } |
1435 } |
1405 |
1436 |
1406 @Override |
1437 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1407 public Type getUpperBound() { |
1438 public Type getUpperBound() { |
1408 if ((bound == null || bound.hasTag(NONE)) && this != tsym.type) { |
1439 if ((bound == null || bound.hasTag(NONE)) && this != tsym.type) { |
1409 bound = tsym.type.getUpperBound(); |
1440 bound = tsym.type.getUpperBound(); |
1410 } |
1441 } |
1411 return bound; |
1442 return bound; |
1412 } |
1443 } |
1413 |
1444 |
1414 int rank_field = -1; |
1445 int rank_field = -1; |
1415 |
1446 |
1416 @Override |
1447 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1417 public Type getLowerBound() { |
1448 public Type getLowerBound() { |
1418 return lower; |
1449 return lower; |
1419 } |
1450 } |
1420 |
1451 |
|
1452 @DefinedBy(Api.LANGUAGE_MODEL) |
1421 public TypeKind getKind() { |
1453 public TypeKind getKind() { |
1422 return TypeKind.TYPEVAR; |
1454 return TypeKind.TYPEVAR; |
1423 } |
1455 } |
1424 |
1456 |
1425 public boolean isCaptured() { |
1457 public boolean isCaptured() { |
1434 @Override |
1466 @Override |
1435 public boolean isNullOrReference() { |
1467 public boolean isNullOrReference() { |
1436 return true; |
1468 return true; |
1437 } |
1469 } |
1438 |
1470 |
1439 @Override |
1471 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1440 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1472 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1441 return v.visitTypeVariable(this, p); |
1473 return v.visitTypeVariable(this, p); |
1442 } |
1474 } |
1443 } |
1475 } |
1444 |
1476 |
1485 @Override |
1517 @Override |
1486 public boolean isCaptured() { |
1518 public boolean isCaptured() { |
1487 return true; |
1519 return true; |
1488 } |
1520 } |
1489 |
1521 |
1490 @Override |
1522 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1491 public String toString() { |
1523 public String toString() { |
1492 StringBuilder sb = new StringBuilder(); |
1524 StringBuilder sb = new StringBuilder(); |
1493 appendAnnotationsString(sb); |
1525 appendAnnotationsString(sb); |
1494 sb.append("capture#"); |
1526 sb.append("capture#"); |
1495 sb.append((hashCode() & 0xFFFFFFFFL) % Printer.PRIME); |
1527 sb.append((hashCode() & 0xFFFFFFFFL) % Printer.PRIME); |
1507 super(qtype.tsym, annos); |
1539 super(qtype.tsym, annos); |
1508 this.tag = tag; |
1540 this.tag = tag; |
1509 this.qtype = qtype; |
1541 this.qtype = qtype; |
1510 } |
1542 } |
1511 public TypeTag getTag() { return tag; } |
1543 public TypeTag getTag() { return tag; } |
|
1544 @DefinedBy(Api.LANGUAGE_MODEL) |
1512 public String toString() { return qtype.toString(); } |
1545 public String toString() { return qtype.toString(); } |
1513 public List<Type> getTypeArguments() { return qtype.getTypeArguments(); } |
1546 public List<Type> getTypeArguments() { return qtype.getTypeArguments(); } |
1514 public Type getEnclosingType() { return qtype.getEnclosingType(); } |
1547 public Type getEnclosingType() { return qtype.getEnclosingType(); } |
1515 public List<Type> getParameterTypes() { return qtype.getParameterTypes(); } |
1548 public List<Type> getParameterTypes() { return qtype.getParameterTypes(); } |
1516 public Type getReturnType() { return qtype.getReturnType(); } |
1549 public Type getReturnType() { return qtype.getReturnType(); } |
1542 @Override |
1575 @Override |
1543 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1576 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1544 return v.visitForAll(this, s); |
1577 return v.visitForAll(this, s); |
1545 } |
1578 } |
1546 |
1579 |
|
1580 @DefinedBy(Api.LANGUAGE_MODEL) |
1547 public String toString() { |
1581 public String toString() { |
1548 StringBuilder sb = new StringBuilder(); |
1582 StringBuilder sb = new StringBuilder(); |
1549 appendAnnotationsString(sb); |
1583 appendAnnotationsString(sb); |
1550 sb.append('<'); |
1584 sb.append('<'); |
1551 sb.append(tvars); |
1585 sb.append(tvars); |
1577 ((TypeVar)l.head).bound.complete(); |
1611 ((TypeVar)l.head).bound.complete(); |
1578 } |
1612 } |
1579 qtype.complete(); |
1613 qtype.complete(); |
1580 } |
1614 } |
1581 |
1615 |
|
1616 @DefinedBy(Api.LANGUAGE_MODEL) |
1582 public List<TypeVar> getTypeVariables() { |
1617 public List<TypeVar> getTypeVariables() { |
1583 return List.convert(TypeVar.class, getTypeArguments()); |
1618 return List.convert(TypeVar.class, getTypeArguments()); |
1584 } |
1619 } |
1585 |
1620 |
|
1621 @DefinedBy(Api.LANGUAGE_MODEL) |
1586 public TypeKind getKind() { |
1622 public TypeKind getKind() { |
1587 return TypeKind.EXECUTABLE; |
1623 return TypeKind.EXECUTABLE; |
1588 } |
1624 } |
1589 |
1625 |
|
1626 @DefinedBy(Api.LANGUAGE_MODEL) |
1590 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1627 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1591 return v.visitExecutable(this, p); |
1628 return v.visitExecutable(this, p); |
1592 } |
1629 } |
1593 } |
1630 } |
1594 |
1631 |
1655 bounds.put(InferenceBound.UPPER, declaredBounds); |
1692 bounds.put(InferenceBound.UPPER, declaredBounds); |
1656 bounds.put(InferenceBound.LOWER, List.<Type>nil()); |
1693 bounds.put(InferenceBound.LOWER, List.<Type>nil()); |
1657 bounds.put(InferenceBound.EQ, List.<Type>nil()); |
1694 bounds.put(InferenceBound.EQ, List.<Type>nil()); |
1658 } |
1695 } |
1659 |
1696 |
|
1697 @DefinedBy(Api.LANGUAGE_MODEL) |
1660 public String toString() { |
1698 public String toString() { |
1661 StringBuilder sb = new StringBuilder(); |
1699 StringBuilder sb = new StringBuilder(); |
1662 appendAnnotationsString(sb); |
1700 appendAnnotationsString(sb); |
1663 if (inst == null) { |
1701 if (inst == null) { |
1664 sb.append(qtype); |
1702 sb.append(qtype); |
1855 @Override |
1893 @Override |
1856 public TypeTag getTag() { |
1894 public TypeTag getTag() { |
1857 return NONE; |
1895 return NONE; |
1858 } |
1896 } |
1859 |
1897 |
1860 @Override |
1898 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1861 public TypeKind getKind() { |
1899 public TypeKind getKind() { |
1862 return TypeKind.NONE; |
1900 return TypeKind.NONE; |
1863 } |
1901 } |
1864 |
1902 |
1865 @Override |
1903 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1866 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1904 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1867 return v.visitNoType(this, p); |
1905 return v.visitNoType(this, p); |
1868 } |
1906 } |
1869 |
1907 |
1870 @Override |
1908 @Override |
1888 @Override |
1926 @Override |
1889 public TypeTag getTag() { |
1927 public TypeTag getTag() { |
1890 return VOID; |
1928 return VOID; |
1891 } |
1929 } |
1892 |
1930 |
1893 @Override |
1931 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1894 public TypeKind getKind() { |
1932 public TypeKind getKind() { |
1895 return TypeKind.VOID; |
1933 return TypeKind.VOID; |
1896 } |
1934 } |
1897 |
1935 |
1898 @Override |
1936 @Override |
1899 public boolean isCompound() { return false; } |
1937 public boolean isCompound() { return false; } |
1900 |
1938 |
1901 @Override |
1939 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1902 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1940 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1903 return v.visitNoType(this, p); |
1941 return v.visitNoType(this, p); |
1904 } |
1942 } |
1905 |
1943 |
1906 @Override |
1944 @Override |
1923 @Override |
1961 @Override |
1924 public TypeTag getTag() { |
1962 public TypeTag getTag() { |
1925 return BOT; |
1963 return BOT; |
1926 } |
1964 } |
1927 |
1965 |
1928 @Override |
1966 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1929 public TypeKind getKind() { |
1967 public TypeKind getKind() { |
1930 return TypeKind.NULL; |
1968 return TypeKind.NULL; |
1931 } |
1969 } |
1932 |
1970 |
1933 @Override |
1971 @Override |
1934 public boolean isCompound() { return false; } |
1972 public boolean isCompound() { return false; } |
1935 |
1973 |
1936 @Override |
1974 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
1937 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1975 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1938 return v.visitNull(this, p); |
1976 return v.visitNull(this, p); |
1939 } |
1977 } |
1940 |
1978 |
1941 @Override |
1979 @Override |
2011 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
2049 public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
2012 return v.visitErrorType(this, s); |
2050 return v.visitErrorType(this, s); |
2013 } |
2051 } |
2014 |
2052 |
2015 public Type constType(Object constValue) { return this; } |
2053 public Type constType(Object constValue) { return this; } |
|
2054 @DefinedBy(Api.LANGUAGE_MODEL) |
2016 public Type getEnclosingType() { return this; } |
2055 public Type getEnclosingType() { return this; } |
2017 public Type getReturnType() { return this; } |
2056 public Type getReturnType() { return this; } |
2018 public Type asSub(Symbol sym) { return this; } |
2057 public Type asSub(Symbol sym) { return this; } |
2019 public Type map(Mapping f) { return this; } |
2058 public Type map(Mapping f) { return this; } |
2020 |
2059 |
2022 public boolean isErroneous() { return true; } |
2061 public boolean isErroneous() { return true; } |
2023 public boolean isCompound() { return false; } |
2062 public boolean isCompound() { return false; } |
2024 public boolean isInterface() { return false; } |
2063 public boolean isInterface() { return false; } |
2025 |
2064 |
2026 public List<Type> allparams() { return List.nil(); } |
2065 public List<Type> allparams() { return List.nil(); } |
|
2066 @DefinedBy(Api.LANGUAGE_MODEL) |
2027 public List<Type> getTypeArguments() { return List.nil(); } |
2067 public List<Type> getTypeArguments() { return List.nil(); } |
2028 |
2068 |
|
2069 @DefinedBy(Api.LANGUAGE_MODEL) |
2029 public TypeKind getKind() { |
2070 public TypeKind getKind() { |
2030 return TypeKind.ERROR; |
2071 return TypeKind.ERROR; |
2031 } |
2072 } |
2032 |
2073 |
2033 public Type getOriginalType() { |
2074 public Type getOriginalType() { |
2034 return originalType; |
2075 return originalType; |
2035 } |
2076 } |
2036 |
2077 |
|
2078 @DefinedBy(Api.LANGUAGE_MODEL) |
2037 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
2079 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
2038 return v.visitError(this, p); |
2080 return v.visitError(this, p); |
2039 } |
2081 } |
2040 } |
2082 } |
2041 |
2083 |
2055 @Override |
2097 @Override |
2056 public TypeTag getTag() { |
2098 public TypeTag getTag() { |
2057 return UNKNOWN; |
2099 return UNKNOWN; |
2058 } |
2100 } |
2059 |
2101 |
2060 @Override |
2102 @Override @DefinedBy(Api.LANGUAGE_MODEL) |
2061 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
2103 public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
2062 return v.visitUnknown(this, p); |
2104 return v.visitUnknown(this, p); |
2063 } |
2105 } |
2064 |
2106 |
2065 @Override |
2107 @Override |