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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart

Issue 15854002: Make sure the type arguments of the supertype of a class are being added to the isCheck set. That s… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | tests/language/type_argument_in_super_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart (revision 23052)
+++ sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart (working copy)
@@ -70,13 +70,17 @@
// If there are no classes that use their variables in checks, there is
// nothing to do.
if (classesUsingChecks.isEmpty) return;
+ Set<DartType> instantiatedTypes = universe.instantiatedTypes;
if (universe.usingFactoryWithTypeArguments) {
- for (DartType type in universe.instantiatedTypes) {
+ for (DartType type in instantiatedTypes) {
if (type.kind != TypeKind.INTERFACE) continue;
InterfaceType interface = type;
- for (DartType argument in interface.typeArguments) {
- universe.isChecks.add(argument);
- }
+ do {
+ for (DartType argument in interface.typeArguments) {
+ universe.isChecks.add(argument);
+ }
+ interface = interface.element.supertype;
+ } while (interface != null && !instantiatedTypes.contains(interface));
}
} else {
// Find all instantiated types that are a subtype of a class that uses
@@ -84,19 +88,22 @@
// set of is-checks.
// TODO(karlklose): replace this with code that uses a subtype lookup
// datastructure in the world.
- for (DartType type in universe.instantiatedTypes) {
+ 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) {
- universe.isChecks.add(argument);
- }
+ InterfaceType current = classType;
+ do {
+ // 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 = current.asInstanceOf(cls);
+ if (instance == null) break;
+ for (DartType argument in instance.typeArguments) {
+ universe.isChecks.add(argument);
+ }
+ current = current.element.supertype;
+ } while (current != null && !instantiatedTypes.contains(current));
}
}
}
« no previous file with comments | « no previous file | tests/language/type_argument_in_super_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698