[ddc] Fix compile time futureOr normalization
Ensure normalization of type argument isn't lost when the FutureOr
itself gets normalized.
Issue: https://github.com/dart-lang/sdk/issues/53250
Change-Id: I5acc616276def5652eec4c1338d92f75bbdffda4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321600
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart b/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart
index a0d83e5..51380c1 100644
--- a/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart
+++ b/pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart
@@ -64,7 +64,7 @@
} else if (futureOr.declaredNullability == Nullability.nullable &&
typeArgument.nullability == Nullability.nullable) {
// FutureOr<T?>? --> FutureOr<T?>
- return futureOr.withDeclaredNullability(Nullability.nonNullable);
+ return FutureOrType(typeArgument, Nullability.nonNullable);
}
// The following is not part of the normalization spec but this is a
// convenient place to perform this change of nullability consistently. This
@@ -80,6 +80,9 @@
typeArgument.declaredNullability == Nullability.undetermined) {
return futureOr.withDeclaredNullability(Nullability.nonNullable);
}
+ if (typeArgument != futureOr.typeArgument) {
+ return FutureOrType(typeArgument, futureOr.declaredNullability);
+ }
return null;
}
}