Fix the migrated splay_tree.dart to make some casts nullable.

I think the covers the cases where it seems reasonable for the value
being cast to be null. In the other places where I see casts, it's
pretty clear that a null is an error.

Change-Id: I38e9b47da72579e7f3849284689d4c25b5b14af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136725
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom 2020-02-21 02:24:46 +00:00 committed by commit-bot@chromium.org
parent 9bedc9a7af
commit 6ef9131d82

View file

@ -166,9 +166,9 @@ abstract class _SplayTree<K, Node extends _SplayTreeNode<K>> {
_count--;
// assert(_count >= 0);
if (_root!.left == null) {
_root = _root!.right as Node;
_root = _root!.right as Node?;
} else {
Node right = _root!.right as Node;
Node? right = _root!.right as Node?;
// Splay to make sure that the new root has an empty right child.
_root = _splayMax(_root!.left as Node);
// Insert the original right child as the right child of the new
@ -429,7 +429,7 @@ class SplayTreeMap<K, V> extends _SplayTree<K, _SplayTreeMapNode<K, V>>
if (node.right != null && visit(node.right as _SplayTreeMapNode)) {
return true;
}
node = node.left as _SplayTreeMapNode;
node = node.left as _SplayTreeMapNode?;
}
return false;
}