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

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: Fix type error. 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: 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;
Lasse Reichstein Nielsen 2013/06/18 14:13:08 Per earlier discussion, could we keep this as "K"?
floitsch 2013/06/20 15:52:50 As discussed in person: leaving as is.
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) {

Powered by Google App Engine
This is Rietveld 408576698