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

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

Issue 10443010: Revert "Fix bug in combination of bounded and exact types." and "Make field final in const class." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 014b82870460b35c06cce7ee74bf859f66d23cb4..8fdde0b0e044484acc9d43492bb5396228dec223 100644
--- a/lib/compiler/implementation/ssa/types.dart
+++ b/lib/compiler/implementation/ssa/types.dart
@@ -605,8 +605,7 @@ class HBoundedType extends HType {
Type computeType(Compiler compiler) => type;
- HType intersection(HType other) {
- if (other.isNull()) return canBeNull() ? HType.NULL : HType.CONFLICTING;
+ HType combine(HType other) {
if (other is HBoundedType) {
HBoundedType temp = other;
// Return [other] in case it is an exact type.
@@ -616,17 +615,23 @@ 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()) {
- return canBeNull() ? this : new HBoundedType(type, true);
- }
- if (other is HBoundedType) {
- HBoundedType temp = other;
- // Return [this] in case [other] is an exact type.
- if (this.type === temp.type) return this;
+ if (canBeNull()) {
+ return this;
+ } else {
+ return new HBoundedType(type, true);
+ }
}
- if (other.isUnknown()) return this;
- return HType.CONFLICTING;
+ return combine(other);
}
}
@@ -639,20 +644,18 @@ class HExactType extends HBoundedType {
return classElement.lookupMember(name);
}
- HType intersection(HType other) {
- if (other is HBoundedType) {
- HBoundedType bounded = other;
- if (this.type === bounded.type) return this;
+ HType combine(HType other) {
+ if (other.isExact()) {
+ HExactType concrete = other;
+ if (this.type === concrete.type) return this;
}
- return super.intersection(other);
+ if (other.isUnknown()) return this;
+ return HType.CONFLICTING;
}
HType union(HType other) {
- if (other is HBoundedType) {
- HBoundedType bounded = other;
- if (this.type === bounded.type) return other;
- }
- return super.union(other);
+ if (other.isNull()) return HType.CONFLICTING;
+ return combine(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