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

Unified Diff: lib/compiler/implementation/ssa/types.dart

Issue 10411094: Fix bug in combination of bounded and exact types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove typo. Created 8 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/switch_this_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/types.dart
diff --git a/lib/compiler/implementation/ssa/types.dart b/lib/compiler/implementation/ssa/types.dart
index 8fdde0b0e044484acc9d43492bb5396228dec223..014b82870460b35c06cce7ee74bf859f66d23cb4 100644
--- a/lib/compiler/implementation/ssa/types.dart
+++ b/lib/compiler/implementation/ssa/types.dart
@@ -605,7 +605,8 @@ class HBoundedType extends HType {
Type computeType(Compiler compiler) => type;
- HType combine(HType other) {
+ HType intersection(HType other) {
+ if (other.isNull()) return canBeNull() ? HType.NULL : HType.CONFLICTING;
if (other is HBoundedType) {
HBoundedType temp = other;
// Return [other] in case it is an exact type.
@@ -615,23 +616,17 @@ class HBoundedType extends HType {
return HType.CONFLICTING;
}
- // As long as we don't keep track of super/sub types for non-primitive types
- // the intersection and union is the same, except when [other] is
- // null.
- HType intersection(HType other) {
- if (other.isNull()) return canBeNull() ? HType.NULL : HType.CONFLICTING;
- return combine(other);
- }
-
HType union(HType other) {
if (other.isNull()) {
- if (canBeNull()) {
- return this;
- } else {
- return new HBoundedType(type, true);
- }
+ return canBeNull() ? this : new HBoundedType(type, true);
}
- return combine(other);
+ if (other is HBoundedType) {
+ HBoundedType temp = other;
+ // Return [this] in case [other] is an exact type.
+ if (this.type === temp.type) return this;
+ }
+ if (other.isUnknown()) return this;
+ return HType.CONFLICTING;
}
}
@@ -644,18 +639,20 @@ class HExactType extends HBoundedType {
return classElement.lookupMember(name);
}
- HType combine(HType other) {
- if (other.isExact()) {
- HExactType concrete = other;
- if (this.type === concrete.type) return this;
+ HType intersection(HType other) {
+ if (other is HBoundedType) {
+ HBoundedType bounded = other;
+ if (this.type === bounded.type) return this;
}
- if (other.isUnknown()) return this;
- return HType.CONFLICTING;
+ return super.intersection(other);
}
HType union(HType other) {
- if (other.isNull()) return HType.CONFLICTING;
- return combine(other);
+ if (other is HBoundedType) {
+ HBoundedType bounded = other;
+ if (this.type === bounded.type) return other;
+ }
+ return super.union(other);
}
}
« no previous file with comments | « no previous file | tests/language/switch_this_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698