[dart2wasm] Fix some errors in FutureOr normalization

This fixes two issues for the cases where `FutureOr` normalizes to
`Future`:

- Normalize to `Future` instead of `_Future`.
- Normalize `FutureOr<Never>?` to `Future<Never>?` instead of
  `Future<Never>`.

Change-Id: I3bcf96c71a7424cecd3872255660fa1513abdfc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271882
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
Aske Simon Christensen 2022-11-25 09:31:37 +00:00 committed by Commit Queue
parent 7759f7fe03
commit ca131dbf6f
2 changed files with 6 additions and 5 deletions

View file

@ -28,8 +28,8 @@ class ClassID {
external static int get cidInt8ArrayView;
@pragma("wasm:class-id", "dart.core#Object")
external static int get cidObject;
@pragma("wasm:class-id", "dart.async#_Future")
external static int get cid_Future;
@pragma("wasm:class-id", "dart.async#Future")
external static int get cidFuture;
@pragma("wasm:class-id", "dart.core#Function")
external static int get cidFunction;
@pragma("wasm:class-id", "dart.core#_Function")

View file

@ -184,7 +184,7 @@ class _FutureOrType extends _Type {
const _FutureOrType(super.isDeclaredNullable, this.typeArgument);
_InterfaceType get asFuture =>
_InterfaceType(ClassID.cid_Future, isDeclaredNullable, [typeArgument]);
_InterfaceType(ClassID.cidFuture, isDeclaredNullable, [typeArgument]);
// Removing a `?` from a type should not require additional normalization.
@override
@ -554,9 +554,10 @@ class _TypeUniverse {
if (isTopType(typeArgument) || isObjectType(typeArgument)) {
return typeArgument;
} else if (typeArgument.isNever) {
return _InterfaceType(ClassID.cid_Future, false, [const _NeverType()]);
return _InterfaceType(
ClassID.cidFuture, isDeclaredNullable, [const _NeverType()]);
} else if (typeArgument.isNull) {
return _InterfaceType(ClassID.cid_Future, true, [const _NullType()]);
return _InterfaceType(ClassID.cidFuture, true, [const _NullType()]);
}
bool declaredNullability =