From 6ef9131d82c4fbc8966f426bb865140ea3b7e860 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Fri, 21 Feb 2020 02:24:46 +0000 Subject: [PATCH] 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 Reviewed-by: Leaf Petersen Commit-Queue: Bob Nystrom --- sdk_nnbd/lib/collection/splay_tree.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk_nnbd/lib/collection/splay_tree.dart b/sdk_nnbd/lib/collection/splay_tree.dart index 8d7f71587c5..6eda337f893 100644 --- a/sdk_nnbd/lib/collection/splay_tree.dart +++ b/sdk_nnbd/lib/collection/splay_tree.dart @@ -166,9 +166,9 @@ abstract class _SplayTree> { _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 extends _SplayTree> if (node.right != null && visit(node.right as _SplayTreeMapNode)) { return true; } - node = node.left as _SplayTreeMapNode; + node = node.left as _SplayTreeMapNode?; } return false; }