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

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

Issue 12210142: Implement is-checks against type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a long line. Created 7 years, 10 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
Index: sdk/lib/_internal/compiler/implementation/world.dart
diff --git a/sdk/lib/_internal/compiler/implementation/world.dart b/sdk/lib/_internal/compiler/implementation/world.dart
index 19a3aaf757cecdb65455ff73478e8402870a823d..7bd6ee22afb0c1256fe05da7613d6579504973c9 100644
--- a/sdk/lib/_internal/compiler/implementation/world.dart
+++ b/sdk/lib/_internal/compiler/implementation/world.dart
@@ -79,12 +79,31 @@ class World {
}
}
+ Set<ClassElement> classesUsingTypeVariableTests = new Set<ClassElement>();
compiler.resolverWorld.isChecks.forEach((DartType type) {
- if (type is InterfaceType) {
+ if (type.kind == TypeKind.TYPE_VARIABLE) {
+ TypeVariableElement variable = type.element;
+ classesUsingTypeVariableTests.add(variable.enclosingElement);
+ }
+ });
+ // Add is-checks that result from classes using type variables in checks.
+ compiler.resolverWorld.addImplicitChecks(classesUsingTypeVariableTests);
+ // Add the rti dependencies that are implicit in the way the backend
+ // generates code: when we create a new [List], we actually create
+ // a JSArray in the backend and we need to add type arguments to
+ // the calls of the list constructor whenever we determine that
+ // JSArray needs type arguments.
+ compiler.backend.addBackendRtiDependencies(this);
+ // Compute the set of all classes that need runtime type information.
+ compiler.resolverWorld.isChecks.forEach((DartType type) {
+ if (type.kind == TypeKind.INTERFACE) {
InterfaceType itf = type;
if (!itf.isRaw) {
potentiallyAddForRti(itf.element);
}
+ } else if (type.kind == TypeKind.TYPE_VARIABLE) {
+ TypeVariableElement variable = type.element;
+ potentiallyAddForRti(variable.enclosingElement);
}
});
}
@@ -102,7 +121,6 @@ class World {
return uses != null && !uses.isEmpty;
}
-
void registerRtiDependency(Element element, Element dependency) {
// We're not dealing with typedef for now.
if (!element.isClass() || !dependency.isClass()) return;

Powered by Google App Engine
This is Rietveld 408576698