Fix null-safety migration error in CastMap.

Make expect use `Never` to signal non-completion instead of depending on `meta`.

Change-Id: Ibb4230e6b0cfbf995ad91a31c6620525cf6a8918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194244
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
Lasse R.H. Nielsen 2021-05-10 14:15:07 +00:00 committed by commit-bot@chromium.org
parent 713b03a5fd
commit 5b64d1233b
2 changed files with 14 additions and 1 deletions

View file

@ -277,7 +277,7 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
_source.addAll(new CastMap<K, V, SK, SV>(other));
}
V remove(Object? key) => _source.remove(key) as V;
V? remove(Object? key) => _source.remove(key) as V?;
void clear() {
_source.clear();

View file

@ -0,0 +1,13 @@
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
void main() {
var map = <String, dynamic>{"a": null};
var castMap = map.cast<String, Object>();
// Should return `null`, not throw.
Expect.isNull(castMap.remove("b"));
Expect.isNull(castMap.remove("a"));
}