Skip to content

Commit

Permalink
Fix dart:collection analysis errors in NNBD fork
Browse files Browse the repository at this point in the history
Change-Id: Id4a5e5b100ca1c429070263555ab730622644d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127161
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
  • Loading branch information
nshahan authored and commit-bot@chromium.org committed Dec 5, 2019
1 parent 88e26cd commit bef857b
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions sdk_nnbd/lib/collection/hash_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ abstract class HashMap<K, V> implements Map<K, V> {
/// If you supply one of [equals] and [hashCode],
/// you should generally also to supply the other.
external factory HashMap(
{bool Function(K key1, K key2)? equals,
int Function(K key)? hashCode,
bool Function(dynamic potentialKey)? isValidKey});
{bool Function(K, K)? equals,
int Function(K)? hashCode,
bool Function(dynamic)? isValidKey});

/// Creates an unordered identity-based map.
///
Expand Down
6 changes: 3 additions & 3 deletions sdk_nnbd/lib/collection/hash_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ abstract class HashSet<E> implements Set<E> {
/// and the `isValidKey` defaults to accepting all keys.
/// Such a map can be created directly using [HashSet.identity].
external factory HashSet(
{bool Function(E e1, E e2)? equals,
int Function(E e)? hashCode,
bool Function(dynamic potentialKey)? isValidKey});
{bool Function(E, E)? equals,
int Function(E)? hashCode,
bool Function(dynamic)? isValidKey});

/// Creates an unordered identity-based set.
///
Expand Down
6 changes: 3 additions & 3 deletions sdk_nnbd/lib/collection/linked_hash_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ abstract class LinkedHashMap<K, V> implements Map<K, V> {
/// If you supply one of [equals] and [hashCode],
/// you should generally also to supply the other.
external factory LinkedHashMap(
{bool Function(K key1, K key2)? equals,
int Function(K key)? hashCode,
bool Function(dynamic potentialKey)? isValidKey});
{bool Function(K, K)? equals,
int Function(K)? hashCode,
bool Function(dynamic)? isValidKey});

/// Creates an insertion-ordered identity-based map.
///
Expand Down
6 changes: 3 additions & 3 deletions sdk_nnbd/lib/collection/linked_hash_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ abstract class LinkedHashSet<E> implements Set<E> {
/// and the `isValidKey` defaults to accepting all keys.
/// Such a map can be created directly using [LinkedHashSet.identity].
external factory LinkedHashSet(
{bool Function(E e1, E e2)? equals,
int Function(E e)? hashCode,
bool Function(dynamic potentialKey)? isValidKey});
{bool Function(E, E)? equals,
int Function(E)? hashCode,
bool Function(dynamic)? isValidKey});

/// Creates an insertion-ordered identity-based set.
///
Expand Down
2 changes: 1 addition & 1 deletion sdk_nnbd/lib/collection/linked_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class LinkedList<E extends LinkedListEntry<E>> extends Iterable<E> {
return;
}
E predecessor = entry!._previous!;
E successor = entry!;
E successor = entry;
newEntry._previous = predecessor;
newEntry._next = successor;
predecessor._next = newEntry;
Expand Down
16 changes: 8 additions & 8 deletions sdk_nnbd/lib/collection/maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ abstract class MapMixin<K, V> implements Map<K, V> {

void addAll(Map<K, V> other) {
for (K key in other.keys) {
this[key] = other[key];
this[key] = other[key] as V;
}
}

Expand Down Expand Up @@ -229,9 +229,9 @@ class _MapBaseValueIterable<K, V> extends EfficientLengthIterable<V> {
int get length => _map.length;
bool get isEmpty => _map.isEmpty;
bool get isNotEmpty => _map.isNotEmpty;
V get first => _map[_map.keys.first];
V get single => _map[_map.keys.single];
V get last => _map[_map.keys.last];
V get first => _map[_map.keys.first] as V;
V get single => _map[_map.keys.single] as V;
V get last => _map[_map.keys.last] as V;

Iterator<V> get iterator => _MapBaseValueIterator<K, V>(_map);
}
Expand Down Expand Up @@ -322,7 +322,7 @@ class MapView<K, V> implements Map<K, V> {
const MapView(Map<K, V> map) : _map = map;

Map<RK, RV> cast<RK, RV>() => _map.cast<RK, RV>();
V operator [](Object key) => _map[key];
V? operator [](Object? key) => _map[key];
void operator []=(K key, V value) {
_map[key] = value;
}
Expand All @@ -336,8 +336,8 @@ class MapView<K, V> implements Map<K, V> {
}

V putIfAbsent(K key, V ifAbsent()) => _map.putIfAbsent(key, ifAbsent);
bool containsKey(Object key) => _map.containsKey(key);
bool containsValue(Object value) => _map.containsValue(value);
bool containsKey(Object? key) => _map.containsKey(key);
bool containsValue(Object? value) => _map.containsValue(value);
void forEach(void action(K key, V value)) {
_map.forEach(action);
}
Expand All @@ -346,7 +346,7 @@ class MapView<K, V> implements Map<K, V> {
bool get isNotEmpty => _map.isNotEmpty;
int get length => _map.length;
Iterable<K> get keys => _map.keys;
V remove(Object key) => _map.remove(key);
V? remove(Object? key) => _map.remove(key);
String toString() => _map.toString();
Iterable<V> get values => _map.values;

Expand Down
6 changes: 3 additions & 3 deletions sdk_nnbd/lib/collection/queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class _DoubleLink<Link extends _DoubleLink<Link>> {
void _link(Link? previous, Link? next) {
_nextLink = next;
_previousLink = previous;
if (previous != null) previous!._nextLink = this as Link;
if (next != null) next!._previousLink = this as Link;
if (previous != null) previous._nextLink = this as Link;
if (next != null) next._previousLink = this as Link;
}

void _unlink() {
Expand Down Expand Up @@ -344,7 +344,7 @@ class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
return result;
}

bool remove(Object o) {
bool remove(Object? o) {
_DoubleLinkedQueueEntry<E> entry =
_sentinel._nextLink as _DoubleLinkedQueueEntry<E>;
while (!identical(entry, _sentinel)) {
Expand Down
12 changes: 6 additions & 6 deletions sdk_nnbd/lib/collection/set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ abstract class SetMixin<E> implements Set<E> {
removeAll(toRemove);
}

bool containsAll(Iterable<Object> other) {
for (Object o in other) {
bool containsAll(Iterable<Object?> other) {
for (var o in other) {
if (!contains(o)) return false;
}
return true;
Expand All @@ -98,15 +98,15 @@ abstract class SetMixin<E> implements Set<E> {
return toSet()..addAll(other);
}

Set<E> intersection(Set<Object> other) {
Set<E> intersection(Set<Object?> other) {
Set<E> result = toSet();
for (E element in this) {
if (!other.contains(element)) result.remove(element);
}
return result;
}

Set<E> difference(Set<Object> other) {
Set<E> difference(Set<Object?> other) {
Set<E> result = toSet();
for (E element in this) {
if (other.contains(element)) result.remove(element);
Expand Down Expand Up @@ -323,15 +323,15 @@ abstract class _SetBase<E> implements Set<E> {

Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newSimilarSet);

Set<E> difference(Set<Object> other) {
Set<E> difference(Set<Object?> other) {
Set<E> result = _newSet();
for (var element in this) {
if (!other.contains(element)) result.add(element);
}
return result;
}

Set<E> intersection(Set<Object> other) {
Set<E> intersection(Set<Object?> other) {
Set<E> result = _newSet();
for (var element in this) {
if (other.contains(element)) result.add(element);
Expand Down
6 changes: 3 additions & 3 deletions sdk_nnbd/lib/collection/splay_tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,12 @@ abstract class _SplayTreeIterator<K, T> implements Iterator<T> {
// Don't include the root, start at the next element after the root.
_findLeftMostDescendent(tree._root!.right);
} else {
_workList.add(tree._root);
_workList.add(tree._root!);
}
}

T? get current {
if (_currentNode == null) return null;
T get current {
if (_currentNode == null) return null as T;
return _getValue(_currentNode!);
}

Expand Down
4 changes: 2 additions & 2 deletions sdk_nnbd/lib/internal/cast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
_source[key as SK] = value as SV;
}

V putIfAbsent(K key, V ifAbsent()) => _source.putIfAbsent(
key as SK, (ifAbsent == null) ? null : () => ifAbsent() as SV) as V;
V putIfAbsent(K key, V Function() ifAbsent) =>
_source.putIfAbsent(key as SK, () => ifAbsent() as SV) as V;

void addAll(Map<K, V> other) {
_source.addAll(new CastMap<K, V, SK, SV>(other));
Expand Down

0 comments on commit bef857b

Please sign in to comment.