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

Unified Diff: lib/coreimpl/hash_map_set.dart

Issue 10979050: Ensure that hashCode and runtimeType work on null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix HashMap. Update bad expectation. Created 8 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
Index: lib/coreimpl/hash_map_set.dart
diff --git a/lib/coreimpl/hash_map_set.dart b/lib/coreimpl/hash_map_set.dart
index 8d5ee2cabb06e4379cfe87b46002f2662b84e697..de7993aacf7003e42e7f43dcaff6937b0e28eb84 100644
--- a/lib/coreimpl/hash_map_set.dart
+++ b/lib/coreimpl/hash_map_set.dart
@@ -69,6 +69,7 @@ class HashMapImplementation<K extends Hashable, V> implements HashMap<K, V> {
}
int _probeForAdding(K key) {
+ if (key == null) throw const NullPointerException();
int hash = _firstProbe(key.hashCode(), _keys.length);
int numberOfProbes = 1;
int initialHash = hash;
@@ -102,6 +103,7 @@ class HashMapImplementation<K extends Hashable, V> implements HashMap<K, V> {
}
int _probeForLookup(K key) {
+ if (key == null) throw const NullPointerException();
int hash = _firstProbe(key.hashCode(), _keys.length);
int numberOfProbes = 1;
int initialHash = hash;
@@ -196,7 +198,7 @@ class HashMapImplementation<K extends Hashable, V> implements HashMap<K, V> {
V putIfAbsent(K key, V ifAbsent()) {
int index = _probeForLookup(key);
- if (index >=0) return _values[index];
+ if (index >= 0) return _values[index];
V value = ifAbsent();
this[key] = value;
« lib/core/map.dart ('K') | « lib/core/map.dart ('k') | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698