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

Unified Diff: sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart

Issue 17017003: Introduce an ElementTypeMask to recognize simple constraints like "the type of parameter foo is the… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/types/union_type_mask.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart (revision 24183)
+++ sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart (working copy)
@@ -20,23 +20,23 @@
return new UnionTypeMask._(disjoint);
}
+ static TypeMask nonForwardingMask(mask) {
+ while (mask.isForwarding) mask = mask.forwardTo;
+ return mask;
+ }
+
static void unionOfHelper(Iterable<TypeMask> masks,
List<FlatTypeMask> disjoint,
Compiler compiler) {
for (TypeMask mask in masks) {
+ mask = nonForwardingMask(mask);
if (mask.isUnion) {
UnionTypeMask union = mask;
unionOfHelper(union.disjointMasks, disjoint, compiler);
} else if (mask.isEmpty && !mask.isNullable) {
continue;
} else {
- FlatTypeMask flatMask;
- if (mask.isContainer) {
- ContainerTypeMask container = mask;
- flatMask = container.asFlat;
- } else {
- flatMask = mask;
- }
+ FlatTypeMask flatMask = mask;
assert(flatMask.base == null
|| flatMask.base.element != compiler.dynamicClass);
int inListIndex = -1;
@@ -146,7 +146,7 @@
}
TypeMask union(var other, Compiler compiler) {
- if (other.isContainer) other = other.asFlat;
+ other = nonForwardingMask(other);
if (!other.isUnion && disjointMasks.contains(other)) return this;
List<FlatTypeMask> newList =
@@ -161,7 +161,7 @@
}
TypeMask intersection(var other, Compiler compiler) {
- if (other.isContainer) other = other.asFlat;
+ other = nonForwardingMask(other);
if (!other.isUnion && disjointMasks.contains(other)) return other;
List<TypeMask> intersections = <TypeMask>[];
@@ -198,6 +198,8 @@
bool get isExact => false;
bool get isUnion => true;
bool get isContainer => false;
+ bool get isForwarding => false;
+ bool get isElement => false;
bool containsOnlyInt(Compiler compiler) => false;
bool containsOnlyDouble(Compiler compiler) => false;

Powered by Google App Engine
This is Rietveld 408576698