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

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

Issue 11315005: Fix for issue #6259: also look for subclasses when checking if a typed selector applies to an eleme… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « lib/compiler/implementation/universe/universe.dart ('k') | tests/language/typed_selector_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/world.dart
===================================================================
--- lib/compiler/implementation/world.dart (revision 14200)
+++ lib/compiler/implementation/world.dart (working copy)
@@ -7,6 +7,7 @@
class World {
final Compiler compiler;
final Map<ClassElement, Set<ClassElement>> subtypes;
+ final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses;
final Set<ClassElement> classesNeedingRti;
final Map<ClassElement, Set<ClassElement>> rtiDependencies;
final FunctionSet userDefinedGetters;
@@ -14,6 +15,8 @@
World(Compiler compiler)
: subtypes = new Map<ClassElement, Set<ClassElement>>(),
+ typesImplementedBySubclasses =
+ new Map<ClassElement, Set<ClassElement>>(),
userDefinedGetters = new FunctionSet(compiler),
userDefinedSetters = new FunctionSet(compiler),
classesNeedingRti = new Set<ClassElement>(),
@@ -26,11 +29,25 @@
compiler.internalErrorOnElement(
cls, 'Class "${cls.name.slowToString()}" is not resolved.');
}
+
for (DartType type in cls.allSupertypes) {
Set<Element> subtypesOfCls =
subtypes.putIfAbsent(type.element, () => new Set<ClassElement>());
subtypesOfCls.add(cls);
}
+
+ // Walk through the superclasses, and record the types
+ // implemented by that type on the superclasses.
+ DartType type = cls.supertype;
+ while (type != null) {
+ Set<Element> typesImplementedBySubclassesOfCls =
+ typesImplementedBySubclasses.putIfAbsent(
+ type.element, () => new Set<ClassElement>());
+ for (DartType current in cls.allSupertypes) {
+ typesImplementedBySubclassesOfCls.add(current.element);
+ }
+ type = type.element.supertype;
+ }
}
compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes);
@@ -106,6 +123,15 @@
return userDefinedSetters.hasAnyElementMatchingSelector(selector);
}
+ // Returns whether a subclass of [superclass] implements [type].
+ bool hasAnySubclassThatImplements(ClassElement superclass, DartType type) {
+ Set<ClassElement> typesImplementedBySubclasses =
+ typesImplementedBySubclasses[superclass];
+ if (typesImplementedBySubclasses == null) return false;
+ return typesImplementedBySubclasses.contains(type.element);
+ }
+
+
void registerUsedElement(Element element) {
if (element.isMember()) {
if (element.isGetter()) {
« no previous file with comments | « lib/compiler/implementation/universe/universe.dart ('k') | tests/language/typed_selector_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698