1066 return qtype.isErroneous(); |
1066 return qtype.isErroneous(); |
1067 } |
1067 } |
1068 |
1068 |
1069 /** |
1069 /** |
1070 * Replaces this ForAll's typevars with a set of concrete Java types |
1070 * Replaces this ForAll's typevars with a set of concrete Java types |
1071 * and returns the instantiated generic type. Subclasses might override |
1071 * and returns the instantiated generic type. Subclasses should override |
1072 * in order to check that the list of types is a valid instantiation |
1072 * in order to check that the list of types is a valid instantiation |
1073 * of the ForAll's typevars. |
1073 * of the ForAll's typevars. |
1074 * |
1074 * |
1075 * @param actuals list of actual types |
1075 * @param actuals list of actual types |
1076 * @param types types instance |
1076 * @param types types instance |
1077 * @return qtype where all occurrences of tvars are replaced |
1077 * @return qtype where all occurrences of tvars are replaced |
1078 * by types in actuals |
1078 * by types in actuals |
1079 */ |
1079 */ |
1080 public Type inst(List<Type> actuals, Types types) { |
1080 public Type inst(List<Type> actuals, Types types) { |
1081 return types.subst(qtype, tvars, actuals); |
1081 return types.subst(qtype, tvars, actuals); |
|
1082 } |
|
1083 |
|
1084 /** |
|
1085 * Kind of type-constraint derived during type inference |
|
1086 */ |
|
1087 public enum ConstraintKind { |
|
1088 /** |
|
1089 * upper bound constraint (a type variable must be instantiated |
|
1090 * with a type T, where T is a subtype of all the types specified by |
|
1091 * its EXTENDS constraints). |
|
1092 */ |
|
1093 EXTENDS, |
|
1094 /** |
|
1095 * lower bound constraint (a type variable must be instantiated |
|
1096 * with a type T, where T is a supertype of all the types specified by |
|
1097 * its SUPER constraints). |
|
1098 */ |
|
1099 SUPER, |
|
1100 /** |
|
1101 * equality constraint (a type variable must be instantiated to the type |
|
1102 * specified by its EQUAL constraint. |
|
1103 */ |
|
1104 EQUAL; |
|
1105 } |
|
1106 |
|
1107 /** |
|
1108 * Get the type-constraints of a given kind for a given type-variable of |
|
1109 * this ForAll type. Subclasses should override in order to return more |
|
1110 * accurate sets of constraints. |
|
1111 * |
|
1112 * @param tv the type-variable for which the constraint is to be retrieved |
|
1113 * @param ck the constraint kind to be retrieved |
|
1114 * @return the list of types specified by the selected constraint |
|
1115 */ |
|
1116 public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) { |
|
1117 return List.nil(); |
1082 } |
1118 } |
1083 |
1119 |
1084 public Type map(Mapping f) { |
1120 public Type map(Mapping f) { |
1085 return f.apply(qtype); |
1121 return f.apply(qtype); |
1086 } |
1122 } |