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

Unified Diff: pkg/compiler/lib/src/elements/types.dart

Issue 2807593002: Use entities in impact transformers. (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/compiler/lib/src/elements/resolution_types.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « pkg/compiler/lib/src/elements/resolution_types.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698