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

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
Index: lib/compiler/implementation/world.dart
===================================================================
--- lib/compiler/implementation/world.dart (revision 14186)
+++ 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,23 @@
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>());
+ typesImplementedBySubclassesOfCls.addAll(cls.allSupertypes);
+ type = type.element.supertype;
+ }
}
compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes);
@@ -106,6 +121,15 @@
return userDefinedSetters.hasAnyElementMatchingSelector(selector);
}
+ // Returnw whether a subclass of [superClass] implements [type].
ahe 2012/10/29 14:22:14 // -> /// Returnw -> Return superclass is one word
ngeoffray 2012/10/29 14:37:53 Done.
+ bool hasOneSubclassThatImplements(ClassElement superClass, Type type) {
sra1 2012/10/29 13:46:10 By 'One' do you mean exactly 1, or 'Any'? Perhaps
ngeoffray 2012/10/29 14:05:38 Good point. Changed 'One' to 'Any' to make it cons
ahe 2012/10/29 14:22:14 superclass is one word
ngeoffray 2012/10/29 14:37:53 Done.
+ Set<ClassElement> typesImplementedBySubclasses =
+ typesImplementedBySubclasses[superClass];
+ if (typesImplementedBySubclasses == null) return false;
+ return typesImplementedBySubclasses.contains(type);
+ }
+
+
void registerUsedElement(Element element) {
if (element.isMember()) {
if (element.isGetter()) {

Powered by Google App Engine
This is Rietveld 408576698