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

Unified Diff: lib/src/canonicalized_map.dart

Issue 1831103004: Fix strong mode warnings. (Closed) Base URL: git@github.com:dart-lang/collection@master
Patch Set: pubspec/changelog Created 4 years, 9 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/src/canonicalized_map.dart
diff --git a/lib/src/canonicalized_map.dart b/lib/src/canonicalized_map.dart
index d967f70d005b5fafd981b4755a4e18b93438b1bf..cc78105eb18a926ade4d1742720715551154a140 100644
--- a/lib/src/canonicalized_map.dart
+++ b/lib/src/canonicalized_map.dart
@@ -6,6 +6,10 @@ import 'dart:collection';
import 'utils.dart';
+typedef C _Canonicalize<C, K>(K key);
+
+typedef bool _IsValidKey(Object key);
+
/// A map whose keys are converted to canonical values of type `C`.
///
/// This is useful for using case-insensitive String keys, for example. It's
@@ -16,9 +20,9 @@ import 'utils.dart';
/// By default, `null` is allowed as a key. It can be forbidden via the
/// `isValidKey` parameter.
class CanonicalizedMap<C, K, V> implements Map<K, V> {
- final Function _canonicalize;
+ final _Canonicalize<C, K> _canonicalize;
- final Function _isValidKeyFn;
+ final _IsValidKey _isValidKeyFn;
final _base = new Map<C, Pair<K, V>>();
@@ -52,7 +56,7 @@ class CanonicalizedMap<C, K, V> implements Map<K, V> {
V operator [](Object key) {
if (!_isValidKey(key)) return null;
- var pair = _base[_canonicalize(key)];
+ var pair = _base[_canonicalize(key as K)];
return pair == null ? null : pair.last;
}
@@ -71,7 +75,7 @@ class CanonicalizedMap<C, K, V> implements Map<K, V> {
bool containsKey(Object key) {
if (!_isValidKey(key)) return false;
- return _base.containsKey(_canonicalize(key));
+ return _base.containsKey(_canonicalize(key as K));
}
bool containsValue(Object value) =>
@@ -96,7 +100,7 @@ class CanonicalizedMap<C, K, V> implements Map<K, V> {
V remove(Object key) {
if (!_isValidKey(key)) return null;
- var pair = _base.remove(_canonicalize(key));
+ var pair = _base.remove(_canonicalize(key as K));
return pair == null ? null : pair.last;
}
« lib/src/algorithms.dart ('K') | « lib/src/algorithms.dart ('k') | lib/src/equality.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698