mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:12:08 +00:00
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:
parent
713b03a5fd
commit
5b64d1233b
|
@ -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();
|
||||
|
|
13
tests/corelib/regress_45473_test.dart
Normal file
13
tests/corelib/regress_45473_test.dart
Normal 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"));
|
||||
}
|
Loading…
Reference in a new issue