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

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

Issue 23672022: Ensure UnionTypeMask.operator== works in the presence of nullability. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/union_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart (revision 27131)
+++ sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart (working copy)
@@ -263,15 +263,26 @@
bool operator==(other) {
if (identical(this, other)) return true;
+
+ bool containsAll() {
+ return other.disjointMasks.every((e) {
+ var map = disjointMasks.map((e) => e.nonNullable());
+ return map.contains(e.nonNullable());
+ });
+ }
+
return other is UnionTypeMask
+ && other.isNullable == isNullable
&& other.disjointMasks.length == disjointMasks.length
- && other.disjointMasks.every((e) => disjointMasks.contains(e));
+ && containsAll();
}
int get hashCode {
- int hashCode = 43;
+ int hashCode = isNullable ? 86 : 43;
+ // The order of the masks in [disjointMasks] must not affect the
+ // hashCode.
for (var mask in disjointMasks) {
- hashCode = (hashCode ^ mask.hashCode) & 0x3fffffff;
+ hashCode = (hashCode ^ mask.nonNullable().hashCode) & 0x3fffffff;
}
return hashCode;
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/union_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698