Skip to content

Commit 5b1a22f

Browse files
mkustermannCommit Bot
authored and
Commit Bot
committed
[vm] Use identical() instead of == in assert()
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/231704 TEST=ci Change-Id: I6c15180fa5c3d242b303cb9fd0ca65c112b40702 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232086 Reviewed-by: Lasse Nielsen <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent 3f1dfdc commit 5b1a22f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sdk/lib/async/future_impl.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@ class _Future<T> implements Future<T> {
604604
/// succeed by the way the function is called.
605605
/// Should be used judiciously.
606606
void _asyncCompleteUnchecked(/*FutureOr<T>*/ dynamic value) {
607-
assert((value as FutureOr<T>) == value);
607+
// Ensure [value] is FutureOr<T>, do so using an `as` check so it works
608+
// also correctly in non-sound null-safety mode.
609+
assert(identical(value as FutureOr<T>, value));
608610
final typedValue = unsafeCast<FutureOr<T>>(value);
609611

610612
// Doing just "is Future" is not sufficient.
@@ -625,7 +627,9 @@ class _Future<T> implements Future<T> {
625627
/// [Future].
626628
/// Should be used judiciously.
627629
void _asyncCompleteUncheckedNoFuture(/*T*/ dynamic value) {
628-
assert((value as T) == value);
630+
// Ensure [value] is T, do so using an `as` check so it works also correctly
631+
// in non-sound null-safety mode.
632+
assert(identical(value as T, value));
629633
_asyncCompleteWithValue(unsafeCast<T>(value));
630634
}
631635

0 commit comments

Comments
 (0)