Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2492)

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/dart_types.dart

Issue 136753002: Version 1.1.0-dev.5.9 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/elements/modelx.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698