Skip to content

Commit be207fb

Browse files
sstricklCommit Bot
authored and
Commit Bot
committed
Revert "[vm] Normalize FutureOr<T?> to FutureOr<T?>?."
This reverts commit d0a1404. Reason for revert: Doesn't follow declared type normalization rules in spec. TEST=Revert Original change's description: > [vm] Normalize FutureOr<T?> to FutureOr<T?>?. > > Previously, FutureOr<T?>? was normalized to FutureOr<T?>, since the two > types are equivalent: FutureOr<T?> is the union of T? and Future<T?>, > and so is nullable since T? allows null. However, this means there are > nullable AbstractTypes where nullability() returns kNonNullable. > > Instead, normalize FutureOr<T?> to FutureOr<T?>?, so that checking the > nullability of the outer type is sufficient to determine nullability. > > TEST=vm/dart/regress_48522 > > Fixed: #48522 > Change-Id: I710facc84ec79485716ee543c9d272f59f87106c > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237061 > Reviewed-by: Martin Kustermann <[email protected]> > Commit-Queue: Tess Strickland <[email protected]> [email protected],[email protected] Change-Id: I6999963d907b9ca79d348aca85bf8949e06471b6 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237081 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 1ffba32 commit be207fb

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

runtime/tests/vm/dart/regress_48522_test.dart

-55
This file was deleted.

runtime/vm/object.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -19847,14 +19847,8 @@ AbstractTypePtr AbstractType::NormalizeFutureOrType(Heap::Space space) const {
1984719847
ASSERT(object_store->nullable_future_null_type() != Type::null());
1984819848
return object_store->nullable_future_null_type();
1984919849
}
19850-
// To avoid having to special case FutureOr in nullability checks, we lift
19851-
// the nullability of the type argument to FutureOr as appropriate.
19852-
if (IsNullable() || unwrapped_type.IsNullable()) {
19853-
// FutureOr<T?> = FutureOr<T?>* = FutureOr<T?>?, so mark as nullable.
19854-
return Type::Cast(*this).ToNullability(Nullability::kNullable, space);
19855-
} else if (unwrapped_type.IsLegacy()) {
19856-
// FutureOr<T*> = FutureOr<T*>*, so mark as legacy.
19857-
return Type::Cast(*this).ToNullability(Nullability::kLegacy, space);
19850+
if (IsNullable() && unwrapped_type.IsNullable()) {
19851+
return Type::Cast(*this).ToNullability(Nullability::kNonNullable, space);
1985819852
}
1985919853
}
1986019854
return ptr();

0 commit comments

Comments
 (0)