Index: sdk/lib/_internal/compiler/implementation/universe/universe.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/universe/universe.dart b/sdk/lib/_internal/compiler/implementation/universe/universe.dart |
index 0b78d6337c6c7bee64d0737244b981d6d94decfb..1e33b8e41573e8851b40d52cd33af407b72821fe 100644 |
--- a/sdk/lib/_internal/compiler/implementation/universe/universe.dart |
+++ b/sdk/lib/_internal/compiler/implementation/universe/universe.dart |
@@ -88,6 +88,42 @@ class Universe { |
bool hasFieldSetter(Element member, Compiler compiler) { |
return fieldSetters.contains(member); |
} |
+ |
+ /** |
+ * Compute type arguments of classes that potentially use their type |
ngeoffray
2013/02/26 14:11:37
Why potentially? We know they are for the resoluti
karlklose
2013/02/27 10:12:58
I meant it may use it, if the method containing it
|
+ * variables in is-checks and add the is-checks that they imply. |
+ * |
+ * This function must be called after all is-checks have been registered. |
+ * |
+ * TODO(karlklose): move these computations into a function producing an |
+ * immutable datastructure. |
+ */ |
+ void addImplicitChecks(Iterable<ClassElement> classesUsingChecks) { |
+ if (!classesUsingChecks.isEmpty) { |
ngeoffray
2013/02/26 14:11:37
How about:
if (classesUsingChecks.isEmpty) return;
karlklose
2013/02/27 10:12:58
Done.
|
+ // Find all instantiated types that are a subtype of a class that uses |
+ // one of its type arguments in an is-check and add the arguments to the |
+ // set of is-checks. |
+ // TODO(karlklose): replace this with code that uses a subtype lookup |
+ // datastructure in the world. |
+ for (DartType type in instantiatedTypes) { |
+ if (type.kind != TypeKind.INTERFACE) { |
+ continue; |
+ } |
+ InterfaceType classType = type; |
+ for (ClassElement cls in classesUsingChecks) { |
+ // We need the type as instance of its superclass anyway, so we just |
+ // try to compute the substitution; if the result is [:null:], the |
+ // classes are not related. |
+ InterfaceType instance = classType.asInstanceOf(cls); |
+ if (instance == null) continue; |
+ Link<DartType> typeArguments = instance.typeArguments; |
+ for (DartType argument in typeArguments) { |
+ isChecks.add(argument); |
+ } |
+ } |
+ } |
+ } |
+ } |
} |
class SelectorKind { |