Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ca131db

Browse files
askeksaCommit Queue
authored and
Commit Queue
committed
[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 <[email protected]> Commit-Queue: Aske Simon Christensen <[email protected]>
1 parent 7759f7f commit ca131db

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

sdk/lib/_internal/wasm/lib/class_id.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class ClassID {
2828
external static int get cidInt8ArrayView;
2929
@pragma("wasm:class-id", "dart.core#Object")
3030
external static int get cidObject;
31-
@pragma("wasm:class-id", "dart.async#_Future")
32-
external static int get cid_Future;
31+
@pragma("wasm:class-id", "dart.async#Future")
32+
external static int get cidFuture;
3333
@pragma("wasm:class-id", "dart.core#Function")
3434
external static int get cidFunction;
3535
@pragma("wasm:class-id", "dart.core#_Function")

sdk/lib/_internal/wasm/lib/type.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class _FutureOrType extends _Type {
184184
const _FutureOrType(super.isDeclaredNullable, this.typeArgument);
185185

186186
_InterfaceType get asFuture =>
187-
_InterfaceType(ClassID.cid_Future, isDeclaredNullable, [typeArgument]);
187+
_InterfaceType(ClassID.cidFuture, isDeclaredNullable, [typeArgument]);
188188

189189
// Removing a `?` from a type should not require additional normalization.
190190
@override
@@ -554,9 +554,10 @@ class _TypeUniverse {
554554
if (isTopType(typeArgument) || isObjectType(typeArgument)) {
555555
return typeArgument;
556556
} else if (typeArgument.isNever) {
557-
return _InterfaceType(ClassID.cid_Future, false, [const _NeverType()]);
557+
return _InterfaceType(
558+
ClassID.cidFuture, isDeclaredNullable, [const _NeverType()]);
558559
} else if (typeArgument.isNull) {
559-
return _InterfaceType(ClassID.cid_Future, true, [const _NullType()]);
560+
return _InterfaceType(ClassID.cidFuture, true, [const _NullType()]);
560561
}
561562

562563
bool declaredNullability =

0 commit comments

Comments
 (0)