| Index: dart/sdk/lib/_internal/compiler/implementation/dart_types.dart
|
| ===================================================================
|
| --- dart/sdk/lib/_internal/compiler/implementation/dart_types.dart (revision 31731)
|
| +++ dart/sdk/lib/_internal/compiler/implementation/dart_types.dart (working copy)
|
| @@ -60,6 +60,11 @@
|
| */
|
| DartType subst(Link<DartType> arguments, Link<DartType> parameters);
|
|
|
| + /// Performs the substitution of the type arguments of [type] for their
|
| + /// corresponding type variables in this type.
|
| + DartType substByContext(GenericType type) =>
|
| + subst(type.typeArguments, type.element.typeVariables);
|
| +
|
| /**
|
| * Returns the unaliased type of this type.
|
| *
|
| @@ -797,8 +802,7 @@
|
| compiler.resolveTypedef(element);
|
| element.checkCyclicReference(compiler);
|
| DartType definition = element.alias.unalias(compiler);
|
| - TypedefType declaration = element.computeType(compiler);
|
| - return definition.subst(typeArguments, declaration.typeArguments);
|
| + return definition.substByContext(this);
|
| }
|
|
|
| int get hashCode => super.hashCode;
|
| @@ -889,10 +893,8 @@
|
| type = element.computeType(compiler);
|
| }
|
| if (!declarer.element.typeVariables.isEmpty) {
|
| - type = type.subst(declarer.typeArguments,
|
| - declarer.element.typeVariables);
|
| - type = type.subst(receiver.typeArguments,
|
| - receiver.element.typeVariables);
|
| + type = type.substByContext(declarer);
|
| + type = type.substByContext(receiver);
|
| }
|
| cachedType = type;
|
| }
|
| @@ -1305,8 +1307,7 @@
|
| Link<DartType> typeVariables = element.typeVariables;
|
| while (!typeVariables.isEmpty && !typeArguments.isEmpty) {
|
| TypeVariableType typeVariable = typeVariables.head;
|
| - DartType bound = typeVariable.element.bound.subst(
|
| - type.typeArguments, element.typeVariables);
|
| + DartType bound = typeVariable.element.bound.substByContext(type);
|
| DartType typeArgument = typeArguments.head;
|
| checkTypeVariableBound(type, typeArgument, typeVariable, bound);
|
| typeVariables = typeVariables.tail;
|
| @@ -1501,13 +1502,10 @@
|
|
|
| /// Returns the set of supertypes of [type] at depth [depth].
|
| Set<DartType> getSupertypesAtDepth(InterfaceType type, int depth) {
|
| - ClassElement cls = type.element;
|
| - OrderedTypeSet types = cls.allSupertypesAndSelf;
|
| - Link<DartType> typeVariables = cls.typeVariables;
|
| - Link<DartType> typeArguments = type.typeArguments;
|
| + OrderedTypeSet types = type.element.allSupertypesAndSelf;
|
| Set<DartType> set = new Set<DartType>();
|
| - types.forEach(depth, (DartType type) {
|
| - set.add(type.subst(typeArguments, typeVariables));
|
| + types.forEach(depth, (DartType supertype) {
|
| + set.add(supertype.substByContext(type));
|
| });
|
| return set;
|
| }
|
|
|