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

Unified Diff: sdk/lib/collection/splay_tree.dart

Issue 14246008: Allow Object when doing lookups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot to upload before committing 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
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | sdk/lib/core/iterable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/splay_tree.dart
diff --git a/sdk/lib/collection/splay_tree.dart b/sdk/lib/collection/splay_tree.dart
index 20cc84cd168512b1538cc332a1638c3e739862c7..84e61e10d4386e01a8e85514a643374b22ad59d9 100644
--- a/sdk/lib/collection/splay_tree.dart
+++ b/sdk/lib/collection/splay_tree.dart
@@ -255,8 +255,9 @@ class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> {
SplayTreeMap._internal();
- V operator [](K key) {
+ V operator [](Object key) {
if (key == null) throw new ArgumentError(key);
+ if (key is! K) return null;
if (_root != null) {
int comp = _splay(key);
if (comp == 0) {
@@ -337,11 +338,11 @@ class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> {
_clear();
}
- bool containsKey(K key) {
- return _splay(key) == 0;
+ bool containsKey(Object key) {
+ return key is K && _splay(key) == 0;
}
- bool containsValue(V value) {
+ bool containsValue(Object value) {
bool found = false;
int initialSplayCount = _splayCount;
bool visit(_SplayTreeMapNode node) {
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | sdk/lib/core/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698