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

Unified Diff: pkg/compiler/lib/src/types/flat_type_mask.dart

Issue 2363773005: Move closed world reasoning methods from ClassWorld to ClosedWorld. (Closed)
Patch Set: Created 4 years, 3 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: pkg/compiler/lib/src/types/flat_type_mask.dart
diff --git a/pkg/compiler/lib/src/types/flat_type_mask.dart b/pkg/compiler/lib/src/types/flat_type_mask.dart
index 0244f8451a6a27cfd41635e40c06c7c0fce65690..1055af23b80a98a6790cf764f688e0d683595d94 100644
--- a/pkg/compiler/lib/src/types/flat_type_mask.dart
+++ b/pkg/compiler/lib/src/types/flat_type_mask.dart
@@ -49,7 +49,7 @@ class FlatTypeMask implements TypeMask {
* [TypeMask.assertIsNormalized] with the factory's result returns `true`.
*/
factory FlatTypeMask.normalized(
- ClassElement base, int flags, ClassWorld world) {
+ ClassElement base, int flags, ClosedWorld world) {
if ((flags >> 1) == EMPTY || ((flags >> 1) == EXACT)) {
return new FlatTypeMask.internal(base, flags);
}
@@ -98,7 +98,7 @@ class FlatTypeMask implements TypeMask {
return isNullable ? new FlatTypeMask.internal(base, flags & ~1) : this;
}
- bool contains(ClassElement type, ClassWorld classWorld) {
+ bool contains(ClassElement type, ClosedWorld closedWorld) {
assert(type.isDeclaration);
if (isEmptyOrNull) {
return false;
@@ -107,43 +107,43 @@ class FlatTypeMask implements TypeMask {
} else if (isExact) {
return false;
} else if (isSubclass) {
- return classWorld.isSubclassOf(type, base);
+ return closedWorld.isSubclassOf(type, base);
} else {
assert(isSubtype);
- return classWorld.isSubtypeOf(type, base);
+ return closedWorld.isSubtypeOf(type, base);
}
}
- bool isSingleImplementationOf(ClassElement cls, ClassWorld classWorld) {
+ bool isSingleImplementationOf(ClassElement cls, ClosedWorld closedWorld) {
// Special case basic types so that, for example, JSString is the
// single implementation of String.
// The general optimization is to realize there is only one class that
// implements [base] and [base] is not instantiated. We however do
// not track correctly the list of truly instantiated classes.
- Backend backend = classWorld.backend;
- if (containsOnlyString(classWorld)) {
- return cls == classWorld.coreClasses.stringClass ||
+ Backend backend = closedWorld.backend;
+ if (containsOnlyString(closedWorld)) {
+ return cls == closedWorld.coreClasses.stringClass ||
cls == backend.stringImplementation;
}
- if (containsOnlyBool(classWorld)) {
- return cls == classWorld.coreClasses.boolClass ||
+ if (containsOnlyBool(closedWorld)) {
+ return cls == closedWorld.coreClasses.boolClass ||
cls == backend.boolImplementation;
}
- if (containsOnlyInt(classWorld)) {
- return cls == classWorld.coreClasses.intClass ||
+ if (containsOnlyInt(closedWorld)) {
+ return cls == closedWorld.coreClasses.intClass ||
cls == backend.intImplementation ||
cls == backend.positiveIntImplementation ||
cls == backend.uint32Implementation ||
cls == backend.uint31Implementation;
}
- if (containsOnlyDouble(classWorld)) {
- return cls == classWorld.coreClasses.doubleClass ||
+ if (containsOnlyDouble(closedWorld)) {
+ return cls == closedWorld.coreClasses.doubleClass ||
cls == backend.doubleImplementation;
}
return false;
}
- bool isInMask(TypeMask other, ClassWorld classWorld) {
+ bool isInMask(TypeMask other, ClosedWorld closedWorld) {
if (isEmptyOrNull) return isNullable ? other.isNullable : true;
// The empty type contains no classes.
if (other.isEmptyOrNull) return false;
@@ -151,7 +151,7 @@ class FlatTypeMask implements TypeMask {
if (isNullable && !other.isNullable) return false;
other = TypeMask.nonForwardingMask(other);
// If other is union, delegate to UnionTypeMask.containsMask.
- if (other is! FlatTypeMask) return other.containsMask(this, classWorld);
+ if (other is! FlatTypeMask) return other.containsMask(this, closedWorld);
// The other must be flat, so compare base and flags.
FlatTypeMask flatOther = other;
ClassElement otherBase = flatOther.base;
@@ -159,7 +159,7 @@ class FlatTypeMask implements TypeMask {
// TODO(herhut): Get rid of isSingleImplementationOf.
if (flatOther.isExact) {
return (isExact && base == otherBase) ||
- isSingleImplementationOf(otherBase, classWorld);
+ isSingleImplementationOf(otherBase, closedWorld);
}
// If other is subclass, this has to be subclass, as well. Unless
// flatOther.base covers all subtypes of this. Currently, we only
@@ -167,50 +167,50 @@ class FlatTypeMask implements TypeMask {
// TODO(herhut): Add check whether flatOther.base is superclass of
// all subclasses of this.base.
if (flatOther.isSubclass) {
- if (isSubtype) return (otherBase == classWorld.coreClasses.objectClass);
- return classWorld.isSubclassOf(base, otherBase);
+ if (isSubtype) return (otherBase == closedWorld.coreClasses.objectClass);
+ return closedWorld.isSubclassOf(base, otherBase);
}
assert(flatOther.isSubtype);
// Check whether this TypeMask satisfies otherBase's interface.
- return satisfies(otherBase, classWorld);
+ return satisfies(otherBase, closedWorld);
}
- bool containsMask(TypeMask other, ClassWorld classWorld) {
- return other.isInMask(this, classWorld);
+ bool containsMask(TypeMask other, ClosedWorld closedWorld) {
+ return other.isInMask(this, closedWorld);
}
- bool containsOnlyInt(ClassWorld classWorld) {
- Backend backend = classWorld.backend;
- return base == classWorld.coreClasses.intClass ||
+ bool containsOnlyInt(ClosedWorld closedWorld) {
+ Backend backend = closedWorld.backend;
+ return base == closedWorld.coreClasses.intClass ||
base == backend.intImplementation ||
base == backend.positiveIntImplementation ||
base == backend.uint31Implementation ||
base == backend.uint32Implementation;
}
- bool containsOnlyDouble(ClassWorld classWorld) {
- Backend backend = classWorld.backend;
- return base == classWorld.coreClasses.doubleClass ||
+ bool containsOnlyDouble(ClosedWorld closedWorld) {
+ Backend backend = closedWorld.backend;
+ return base == closedWorld.coreClasses.doubleClass ||
base == backend.doubleImplementation;
}
- bool containsOnlyNum(ClassWorld classWorld) {
- Backend backend = classWorld.backend;
- return containsOnlyInt(classWorld) ||
- containsOnlyDouble(classWorld) ||
- base == classWorld.coreClasses.numClass ||
+ bool containsOnlyNum(ClosedWorld closedWorld) {
+ Backend backend = closedWorld.backend;
+ return containsOnlyInt(closedWorld) ||
+ containsOnlyDouble(closedWorld) ||
+ base == closedWorld.coreClasses.numClass ||
base == backend.numImplementation;
}
- bool containsOnlyBool(ClassWorld classWorld) {
- Backend backend = classWorld.backend;
- return base == classWorld.coreClasses.boolClass ||
+ bool containsOnlyBool(ClosedWorld closedWorld) {
+ Backend backend = closedWorld.backend;
+ return base == closedWorld.coreClasses.boolClass ||
base == backend.boolImplementation;
}
- bool containsOnlyString(ClassWorld classWorld) {
- Backend backend = classWorld.backend;
- return base == classWorld.coreClasses.stringClass ||
+ bool containsOnlyString(ClosedWorld closedWorld) {
+ Backend backend = closedWorld.backend;
+ return base == closedWorld.coreClasses.stringClass ||
base == backend.stringImplementation;
}
@@ -219,10 +219,10 @@ class FlatTypeMask implements TypeMask {
return base == cls;
}
- bool satisfies(ClassElement cls, ClassWorld classWorld) {
+ bool satisfies(ClassElement cls, ClosedWorld closedWorld) {
assert(cls.isDeclaration);
if (isEmptyOrNull) return false;
- if (classWorld.isSubtypeOf(base, cls)) return true;
+ if (closedWorld.isSubtypeOf(base, cls)) return true;
return false;
}
@@ -230,13 +230,13 @@ class FlatTypeMask implements TypeMask {
* Returns the [ClassElement] if this type represents a single class,
* otherwise returns `null`. This method is conservative.
*/
- ClassElement singleClass(ClassWorld classWorld) {
+ ClassElement singleClass(ClosedWorld closedWorld) {
if (isEmptyOrNull) return null;
if (isNullable) return null; // It is Null and some other class.
if (isExact) {
return base;
} else if (isSubclass) {
- return classWorld.hasAnyStrictSubclass(base) ? null : base;
+ return closedWorld.hasAnyStrictSubclass(base) ? null : base;
} else {
assert(isSubtype);
return null;
@@ -246,40 +246,40 @@ class FlatTypeMask implements TypeMask {
/**
* Returns whether or not this type mask contains all types.
*/
- bool containsAll(ClassWorld classWorld) {
+ bool containsAll(ClosedWorld closedWorld) {
if (isEmptyOrNull || isExact) return false;
- return identical(base, classWorld.coreClasses.objectClass);
+ return identical(base, closedWorld.coreClasses.objectClass);
}
- TypeMask union(TypeMask other, ClassWorld classWorld) {
+ TypeMask union(TypeMask other, ClosedWorld closedWorld) {
assert(other != null);
- assert(TypeMask.assertIsNormalized(this, classWorld));
- assert(TypeMask.assertIsNormalized(other, classWorld));
- if (other is! FlatTypeMask) return other.union(this, classWorld);
+ assert(TypeMask.assertIsNormalized(this, closedWorld));
+ assert(TypeMask.assertIsNormalized(other, closedWorld));
+ if (other is! FlatTypeMask) return other.union(this, closedWorld);
FlatTypeMask flatOther = other;
if (isEmptyOrNull) {
return isNullable ? flatOther.nullable() : flatOther;
} else if (flatOther.isEmptyOrNull) {
return flatOther.isNullable ? nullable() : this;
} else if (base == flatOther.base) {
- return unionSame(flatOther, classWorld);
- } else if (classWorld.isSubclassOf(flatOther.base, base)) {
- return unionStrictSubclass(flatOther, classWorld);
- } else if (classWorld.isSubclassOf(base, flatOther.base)) {
- return flatOther.unionStrictSubclass(this, classWorld);
- } else if (classWorld.isSubtypeOf(flatOther.base, base)) {
- return unionStrictSubtype(flatOther, classWorld);
- } else if (classWorld.isSubtypeOf(base, flatOther.base)) {
- return flatOther.unionStrictSubtype(this, classWorld);
+ return unionSame(flatOther, closedWorld);
+ } else if (closedWorld.isSubclassOf(flatOther.base, base)) {
+ return unionStrictSubclass(flatOther, closedWorld);
+ } else if (closedWorld.isSubclassOf(base, flatOther.base)) {
+ return flatOther.unionStrictSubclass(this, closedWorld);
+ } else if (closedWorld.isSubtypeOf(flatOther.base, base)) {
+ return unionStrictSubtype(flatOther, closedWorld);
+ } else if (closedWorld.isSubtypeOf(base, flatOther.base)) {
+ return flatOther.unionStrictSubtype(this, closedWorld);
} else {
return new UnionTypeMask._internal(<FlatTypeMask>[this, flatOther]);
}
}
- TypeMask unionSame(FlatTypeMask other, ClassWorld classWorld) {
+ TypeMask unionSame(FlatTypeMask other, ClosedWorld closedWorld) {
assert(base == other.base);
- assert(TypeMask.assertIsNormalized(this, classWorld));
- assert(TypeMask.assertIsNormalized(other, classWorld));
+ assert(TypeMask.assertIsNormalized(this, closedWorld));
+ assert(TypeMask.assertIsNormalized(other, closedWorld));
// The two masks share the base type, so we must chose the least
// constraining kind (the highest) of the two. If either one of
// the masks are nullable the result should be nullable too.
@@ -292,18 +292,18 @@ class FlatTypeMask implements TypeMask {
} else if (other.flags == combined) {
return other;
} else {
- return new FlatTypeMask.normalized(base, combined, classWorld);
+ return new FlatTypeMask.normalized(base, combined, closedWorld);
}
}
- TypeMask unionStrictSubclass(FlatTypeMask other, ClassWorld classWorld) {
+ TypeMask unionStrictSubclass(FlatTypeMask other, ClosedWorld closedWorld) {
assert(base != other.base);
- assert(classWorld.isSubclassOf(other.base, base));
- assert(TypeMask.assertIsNormalized(this, classWorld));
- assert(TypeMask.assertIsNormalized(other, classWorld));
+ assert(closedWorld.isSubclassOf(other.base, base));
+ assert(TypeMask.assertIsNormalized(this, closedWorld));
+ assert(TypeMask.assertIsNormalized(other, closedWorld));
int combined;
if ((isExact && other.isExact) ||
- base == classWorld.coreClasses.objectClass) {
+ base == closedWorld.coreClasses.objectClass) {
// Since the other mask is a subclass of this mask, we need the
// resulting union to be a subclass too. If either one of the
// masks are nullable the result should be nullable too.
@@ -319,16 +319,16 @@ class FlatTypeMask implements TypeMask {
// If we weaken the constraint on this type, we have to make sure that
// the result is normalized.
return (flags != combined)
- ? new FlatTypeMask.normalized(base, combined, classWorld)
+ ? new FlatTypeMask.normalized(base, combined, closedWorld)
: this;
}
- TypeMask unionStrictSubtype(FlatTypeMask other, ClassWorld classWorld) {
+ TypeMask unionStrictSubtype(FlatTypeMask other, ClosedWorld closedWorld) {
assert(base != other.base);
- assert(!classWorld.isSubclassOf(other.base, base));
- assert(classWorld.isSubtypeOf(other.base, base));
- assert(TypeMask.assertIsNormalized(this, classWorld));
- assert(TypeMask.assertIsNormalized(other, classWorld));
+ assert(!closedWorld.isSubclassOf(other.base, base));
+ assert(closedWorld.isSubtypeOf(other.base, base));
+ assert(TypeMask.assertIsNormalized(this, closedWorld));
+ assert(TypeMask.assertIsNormalized(other, closedWorld));
// Since the other mask is a subtype of this mask, we need the
// resulting union to be a subtype too. If either one of the masks
// are nullable the result should be nullable too.
@@ -336,37 +336,37 @@ class FlatTypeMask implements TypeMask {
// We know there is at least one subtype, [other.base], so no need
// to normalize.
return (flags != combined)
- ? new FlatTypeMask.normalized(base, combined, classWorld)
+ ? new FlatTypeMask.normalized(base, combined, closedWorld)
: this;
}
- TypeMask intersection(TypeMask other, ClassWorld classWorld) {
+ TypeMask intersection(TypeMask other, ClosedWorld closedWorld) {
assert(other != null);
- if (other is! FlatTypeMask) return other.intersection(this, classWorld);
- assert(TypeMask.assertIsNormalized(this, classWorld));
- assert(TypeMask.assertIsNormalized(other, classWorld));
+ if (other is! FlatTypeMask) return other.intersection(this, closedWorld);
+ assert(TypeMask.assertIsNormalized(this, closedWorld));
+ assert(TypeMask.assertIsNormalized(other, closedWorld));
FlatTypeMask flatOther = other;
if (isEmptyOrNull) {
return flatOther.isNullable ? this : nonNullable();
} else if (flatOther.isEmptyOrNull) {
return isNullable ? flatOther : other.nonNullable();
} else if (base == flatOther.base) {
- return intersectionSame(flatOther, classWorld);
- } else if (classWorld.isSubclassOf(flatOther.base, base)) {
- return intersectionStrictSubclass(flatOther, classWorld);
- } else if (classWorld.isSubclassOf(base, flatOther.base)) {
- return flatOther.intersectionStrictSubclass(this, classWorld);
- } else if (classWorld.isSubtypeOf(flatOther.base, base)) {
- return intersectionStrictSubtype(flatOther, classWorld);
- } else if (classWorld.isSubtypeOf(base, flatOther.base)) {
- return flatOther.intersectionStrictSubtype(this, classWorld);
+ return intersectionSame(flatOther, closedWorld);
+ } else if (closedWorld.isSubclassOf(flatOther.base, base)) {
+ return intersectionStrictSubclass(flatOther, closedWorld);
+ } else if (closedWorld.isSubclassOf(base, flatOther.base)) {
+ return flatOther.intersectionStrictSubclass(this, closedWorld);
+ } else if (closedWorld.isSubtypeOf(flatOther.base, base)) {
+ return intersectionStrictSubtype(flatOther, closedWorld);
+ } else if (closedWorld.isSubtypeOf(base, flatOther.base)) {
+ return flatOther.intersectionStrictSubtype(this, closedWorld);
} else {
- return intersectionDisjoint(flatOther, classWorld);
+ return intersectionDisjoint(flatOther, closedWorld);
}
}
- bool isDisjoint(TypeMask other, ClassWorld classWorld) {
- if (other is! FlatTypeMask) return other.isDisjoint(this, classWorld);
+ bool isDisjoint(TypeMask other, ClosedWorld closedWorld) {
+ if (other is! FlatTypeMask) return other.isDisjoint(this, closedWorld);
FlatTypeMask flatOther = other;
if (isNullable && flatOther.isNullable) return false;
@@ -374,39 +374,39 @@ class FlatTypeMask implements TypeMask {
if (base == flatOther.base) return false;
if (isExact && flatOther.isExact) return true;
- if (isExact) return !flatOther.contains(base, classWorld);
- if (flatOther.isExact) return !contains(flatOther.base, classWorld);
+ if (isExact) return !flatOther.contains(base, closedWorld);
+ if (flatOther.isExact) return !contains(flatOther.base, closedWorld);
// Normalization guarantees that isExact === !isSubclass && !isSubtype.
// Both are subclass or subtype masks, so if there is a subclass
// relationship, they are not disjoint.
- if (classWorld.isSubclassOf(flatOther.base, base)) return false;
- if (classWorld.isSubclassOf(base, flatOther.base)) return false;
+ if (closedWorld.isSubclassOf(flatOther.base, base)) return false;
+ if (closedWorld.isSubclassOf(base, flatOther.base)) return false;
// Two different base classes have no common subclass unless one is a
// subclass of the other (checked above).
if (isSubclass && flatOther.isSubclass) return true;
- return _isDisjointHelper(this, flatOther, classWorld);
+ return _isDisjointHelper(this, flatOther, closedWorld);
}
static bool _isDisjointHelper(
- FlatTypeMask a, FlatTypeMask b, ClassWorld classWorld) {
+ FlatTypeMask a, FlatTypeMask b, ClosedWorld closedWorld) {
if (!a.isSubclass && b.isSubclass) {
- return _isDisjointHelper(b, a, classWorld);
+ return _isDisjointHelper(b, a, closedWorld);
}
assert(a.isSubclass || a.isSubtype);
assert(b.isSubtype);
var elements = a.isSubclass
- ? classWorld.strictSubclassesOf(a.base)
- : classWorld.strictSubtypesOf(a.base);
+ ? closedWorld.strictSubclassesOf(a.base)
+ : closedWorld.strictSubtypesOf(a.base);
for (var element in elements) {
- if (classWorld.isSubtypeOf(element, b.base)) return false;
+ if (closedWorld.isSubtypeOf(element, b.base)) return false;
}
return true;
}
- TypeMask intersectionSame(FlatTypeMask other, ClassWorld classWorld) {
+ TypeMask intersectionSame(FlatTypeMask other, ClosedWorld closedWorld) {
assert(base == other.base);
// The two masks share the base type, so we must chose the most
// constraining kind (the lowest) of the two. Only if both masks
@@ -420,14 +420,14 @@ class FlatTypeMask implements TypeMask {
} else if (other.flags == combined) {
return other;
} else {
- return new FlatTypeMask.normalized(base, combined, classWorld);
+ return new FlatTypeMask.normalized(base, combined, closedWorld);
}
}
TypeMask intersectionStrictSubclass(
- FlatTypeMask other, ClassWorld classWorld) {
+ FlatTypeMask other, ClosedWorld closedWorld) {
assert(base != other.base);
- assert(classWorld.isSubclassOf(other.base, base));
+ assert(closedWorld.isSubclassOf(other.base, base));
// If this mask isn't at least a subclass mask, then the
// intersection with the other mask is empty.
if (isExact) return intersectionEmpty(other);
@@ -440,15 +440,15 @@ class FlatTypeMask implements TypeMask {
if (other.flags == combined) {
return other;
} else {
- return new FlatTypeMask.normalized(other.base, combined, classWorld);
+ return new FlatTypeMask.normalized(other.base, combined, closedWorld);
}
}
TypeMask intersectionStrictSubtype(
- FlatTypeMask other, ClassWorld classWorld) {
+ FlatTypeMask other, ClosedWorld closedWorld) {
assert(base != other.base);
- assert(classWorld.isSubtypeOf(other.base, base));
- if (!isSubtype) return intersectionHelper(other, classWorld);
+ assert(closedWorld.isSubtypeOf(other.base, base));
+ if (!isSubtype) return intersectionHelper(other, closedWorld);
// Only the other mask puts constraints on the intersection mask,
// so base the combined flags on the other mask. Only if both
// masks are nullable, will the result be nullable too.
@@ -458,21 +458,21 @@ class FlatTypeMask implements TypeMask {
if (other.flags == combined) {
return other;
} else {
- return new FlatTypeMask.normalized(other.base, combined, classWorld);
+ return new FlatTypeMask.normalized(other.base, combined, closedWorld);
}
}
- TypeMask intersectionDisjoint(FlatTypeMask other, ClassWorld classWorld) {
+ TypeMask intersectionDisjoint(FlatTypeMask other, ClosedWorld closedWorld) {
assert(base != other.base);
- assert(!classWorld.isSubtypeOf(base, other.base));
- assert(!classWorld.isSubtypeOf(other.base, base));
- return intersectionHelper(other, classWorld);
+ assert(!closedWorld.isSubtypeOf(base, other.base));
+ assert(!closedWorld.isSubtypeOf(other.base, base));
+ return intersectionHelper(other, closedWorld);
}
- TypeMask intersectionHelper(FlatTypeMask other, ClassWorld classWorld) {
+ TypeMask intersectionHelper(FlatTypeMask other, ClosedWorld closedWorld) {
assert(base != other.base);
- assert(!classWorld.isSubclassOf(base, other.base));
- assert(!classWorld.isSubclassOf(other.base, base));
+ assert(!closedWorld.isSubclassOf(base, other.base));
+ assert(!closedWorld.isSubclassOf(other.base, base));
// If one of the masks are exact or if both of them are subclass
// masks, then the intersection is empty.
if (isExact || other.isExact) return intersectionEmpty(other);
@@ -480,7 +480,7 @@ class FlatTypeMask implements TypeMask {
assert(isSubtype || other.isSubtype);
int kind = (isSubclass || other.isSubclass) ? SUBCLASS : SUBTYPE;
// Compute the set of classes that are contained in both type masks.
- Set<ClassElement> common = commonContainedClasses(this, other, classWorld);
+ Set<ClassElement> common = commonContainedClasses(this, other, closedWorld);
if (common == null || common.isEmpty) return intersectionEmpty(other);
// Narrow down the candidates by only looking at common classes
// that do not have a superclass or supertype that will be a
@@ -505,9 +505,9 @@ class FlatTypeMask implements TypeMask {
// to normalize here, as we generate types based on new base classes.
int combined = (kind << 1) | (flags & other.flags & 1);
Iterable<TypeMask> masks = candidates.map((ClassElement cls) {
- return new FlatTypeMask.normalized(cls, combined, classWorld);
+ return new FlatTypeMask.normalized(cls, combined, closedWorld);
});
- return UnionTypeMask.unionOf(masks, classWorld);
+ return UnionTypeMask.unionOf(masks, closedWorld);
}
TypeMask intersectionEmpty(FlatTypeMask other) {
@@ -542,8 +542,8 @@ class FlatTypeMask implements TypeMask {
* invoked on this type mask. [selector] is used to ensure library
* privacy is taken into account.
*/
- bool canHit(Element element, Selector selector, ClassWorld classWorld) {
- Backend backend = classWorld.backend;
+ bool canHit(Element element, Selector selector, ClosedWorld closedWorld) {
+ Backend backend = closedWorld.backend;
assert(element.name == selector.name);
if (isEmpty) return false;
if (isNull) {
@@ -565,25 +565,25 @@ class FlatTypeMask implements TypeMask {
} else if (isExact) {
return hasElementIn(self, selector, element);
} else if (isSubclass) {
- assert(classWorld.isClosed);
+ assert(closedWorld.isClosed);
return hasElementIn(self, selector, element) ||
other.isSubclassOf(self) ||
- classWorld.hasAnySubclassThatMixes(self, other);
+ closedWorld.hasAnySubclassThatMixes(self, other);
} else {
assert(isSubtype);
- assert(classWorld.isClosed);
+ assert(closedWorld.isClosed);
bool result = hasElementIn(self, selector, element) ||
other.implementsInterface(self) ||
- classWorld.hasAnySubclassThatImplements(other, base) ||
- classWorld.hasAnySubclassOfMixinUseThatImplements(other, base);
+ closedWorld.hasAnySubclassThatImplements(other, base) ||
+ closedWorld.hasAnySubclassOfMixinUseThatImplements(other, base);
if (result) return true;
// If the class is used as a mixin, we have to check if the element
// can be hit from any of the mixin applications.
- Iterable<ClassElement> mixinUses = classWorld.mixinUsesOf(self);
+ Iterable<ClassElement> mixinUses = closedWorld.mixinUsesOf(self);
return mixinUses.any((mixinApplication) =>
hasElementIn(mixinApplication, selector, element) ||
other.isSubclassOf(mixinApplication) ||
- classWorld.hasAnySubclassThatMixes(mixinApplication, other));
+ closedWorld.hasAnySubclassThatMixes(mixinApplication, other));
}
}
@@ -592,7 +592,7 @@ class FlatTypeMask implements TypeMask {
* will hit a method at runtime, and not go through [noSuchMethod].
*/
static bool hasConcreteMatch(
- ClassElement cls, Selector selector, ClassWorld world) {
+ ClassElement cls, Selector selector, ClosedWorld world) {
assert(invariant(cls, world.isInstantiated(cls),
message: '$cls has not been instantiated.'));
Element element = findMatchIn(cls, selector);
@@ -605,7 +605,7 @@ class FlatTypeMask implements TypeMask {
return selector.appliesUntyped(element, world.backend);
}
- bool needsNoSuchMethodHandling(Selector selector, ClassWorld classWorld) {
+ bool needsNoSuchMethodHandling(Selector selector, ClosedWorld closedWorld) {
// A call on an empty type mask is either dead code, or a call on
// `null`.
if (isEmptyOrNull) return false;
@@ -658,14 +658,14 @@ class FlatTypeMask implements TypeMask {
bool needsNoSuchMethod(ClassElement cls) {
// We can skip uninstantiated subclasses.
// TODO(johnniwinther): Put filtering into the (Class)World.
- if (!classWorld.isInstantiated(cls)) {
+ if (!closedWorld.isInstantiated(cls)) {
return false;
}
// We can just skip abstract classes because we know no
// instance of them will be created at runtime, and
// therefore there is no instance that will require
// [noSuchMethod] handling.
- return !cls.isAbstract && !hasConcreteMatch(cls, selector, classWorld);
+ return !cls.isAbstract && !hasConcreteMatch(cls, selector, closedWorld);
}
bool baseNeedsNoSuchMethod = needsNoSuchMethod(base);
@@ -675,10 +675,10 @@ class FlatTypeMask implements TypeMask {
Iterable<ClassElement> subclassesToCheck;
if (isSubtype) {
- subclassesToCheck = classWorld.strictSubtypesOf(base);
+ subclassesToCheck = closedWorld.strictSubtypesOf(base);
} else {
assert(isSubclass);
- subclassesToCheck = classWorld.strictSubclassesOf(base);
+ subclassesToCheck = closedWorld.strictSubclassesOf(base);
}
return subclassesToCheck != null &&
@@ -696,17 +696,17 @@ class FlatTypeMask implements TypeMask {
// all classes in the receiver type [this]. It could be found only in a
// subclass or in an inheritance-wise unrelated class in case of subtype
// selectors.
- ClassWorld classWorld = compiler.closedWorld;
+ ClosedWorld closedWorld = compiler.closedWorld;
if (isSubtype) {
- // if (classWorld.isUsedAsMixin(enclosing)) {
- if (classWorld.everySubtypeIsSubclassOfOrMixinUseOf(base, enclosing)) {
+ // if (closedWorld.isUsedAsMixin(enclosing)) {
+ if (closedWorld.everySubtypeIsSubclassOfOrMixinUseOf(base, enclosing)) {
return result;
}
//}
return null;
} else {
if (base.isSubclassOf(enclosing)) return result;
- if (classWorld.isSubclassOfMixinUseOf(base, enclosing)) return result;
+ if (closedWorld.isSubclassOfMixinUseOf(base, enclosing)) return result;
}
return null;
}
@@ -734,24 +734,24 @@ class FlatTypeMask implements TypeMask {
}
static Set<ClassElement> commonContainedClasses(
- FlatTypeMask x, FlatTypeMask y, ClassWorld classWorld) {
- Iterable<ClassElement> xSubset = containedSubset(x, classWorld);
+ FlatTypeMask x, FlatTypeMask y, ClosedWorld closedWorld) {
+ Iterable<ClassElement> xSubset = containedSubset(x, closedWorld);
if (xSubset == null) return null;
- Iterable<ClassElement> ySubset = containedSubset(y, classWorld);
+ Iterable<ClassElement> ySubset = containedSubset(y, closedWorld);
if (ySubset == null) return null;
return xSubset.toSet().intersection(ySubset.toSet());
}
static Iterable<ClassElement> containedSubset(
- FlatTypeMask x, ClassWorld classWorld) {
+ FlatTypeMask x, ClosedWorld closedWorld) {
ClassElement element = x.base;
if (x.isExact) {
return null;
} else if (x.isSubclass) {
- return classWorld.strictSubclassesOf(element);
+ return closedWorld.strictSubclassesOf(element);
} else {
assert(x.isSubtype);
- return classWorld.strictSubtypesOf(element);
+ return closedWorld.strictSubtypesOf(element);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698