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

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

Issue 17569004: Implement hashCode on objects stored in a set or used as map keys. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
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: dart/sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart b/dart/sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart
index 8f1a4ff826ea252d7b5707a84ae4376aab3fabf1..ed4eb2bfde7e2486094dcb60b8b6080ae19beddd 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/types/union_type_mask.dart
@@ -266,4 +266,12 @@ class UnionTypeMask implements TypeMask {
&& other.disjointMasks.length == disjointMasks.length
&& other.disjointMasks.every((e) => disjointMasks.contains(e));
}
+
+ int get hashCode {
+ int hashCode = 43;
+ for (var mask in disjointMasks) {
+ hashCode = (hashCode ^ mask.hashCode) & 0x3fffffff;
+ }
+ return hashCode;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698