Index: pkg/compiler/lib/src/elements/types.dart |
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart |
index f169ef21f0e43b360f7e1573e7c8f30377859aaf..e61b313ce0b764323a69be838e30bdd6aec46619 100644 |
--- a/pkg/compiler/lib/src/elements/types.dart |
+++ b/pkg/compiler/lib/src/elements/types.dart |
@@ -62,6 +62,10 @@ abstract class DartType { |
/// Whether this type contains a type variable. |
bool get containsTypeVariables => false; |
+ |
+ /// Applies [f] to each occurence of a [ResolutionTypeVariableType] within |
+ /// this type. |
+ void forEachTypeVariable(f(TypeVariableType variable)) {} |
} |
class InterfaceType extends DartType { |
@@ -73,6 +77,10 @@ class InterfaceType extends DartType { |
bool get containsTypeVariables => |
typeArguments.any((type) => type.containsTypeVariables); |
+ void forEachTypeVariable(f(TypeVariableType variable)) { |
+ typeArguments.forEach((type) => type.forEachTypeVariable(f)); |
+ } |
+ |
int get hashCode { |
int hash = element.hashCode; |
for (DartType argument in typeArguments) { |
@@ -116,6 +124,10 @@ class TypeVariableType extends DartType { |
bool get containsTypeVariables => true; |
+ void forEachTypeVariable(f(TypeVariableType variable)) { |
+ f(this); |
+ } |
+ |
int get hashCode => 17 * element.hashCode; |
bool operator ==(other) { |
@@ -176,6 +188,13 @@ class FunctionType extends DartType { |
namedParameterTypes.any((type) => type.containsTypeVariables); |
} |
+ void forEachTypeVariable(f(TypeVariableType variable)) { |
+ returnType.forEachTypeVariable(f); |
+ parameterTypes.forEach((type) => type.forEachTypeVariable(f)); |
+ optionalParameterTypes.forEach((type) => type.forEachTypeVariable(f)); |
+ namedParameterTypes.forEach((type) => type.forEachTypeVariable(f)); |
+ } |
+ |
bool get isFunctionType => true; |
int get hashCode { |