Skip to content

Commit 07e2921

Browse files
nshahancommit-bot@chromium.org
authored andcommitted
[ddc] Cleanup false assumption from subtype check
FutureOr<A> <: FutureOr<B> iff A <: B was proven to not always be true. Changing this to simply an optimization and no longer "if and only if". Change-Id: I46f228933df65a86c2c525a48f11b18397b7c48c Fixes: #38818 Fixes: #42326 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151325 Reviewed-by: Mark Zhou <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]>
1 parent 62893f9 commit 07e2921

File tree

2 files changed

+8
-8
lines changed
  • sdk_nnbd/lib/_internal/js_dev_runtime/private/ddc_runtime
  • sdk/lib/_internal/js_dev_runtime/private/ddc_runtime

2 files changed

+8
-8
lines changed

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,10 +1415,10 @@ bool _isSubtype(t1, t2, @notNull bool strictMode) => JS<bool>('!', '''(() => {
14151415
let t1TypeArg = ${getGenericArgs(t1)}[0];
14161416
if (${_isFutureOr(t2)}) {
14171417
let t2TypeArg = ${getGenericArgs(t2)}[0];
1418-
// FutureOr<A> <: FutureOr<B> iff A <: B
1419-
// TODO(nshahan): Proven to not actually be true and needs cleanup.
1420-
// https://github.com/dart-lang/sdk/issues/38818
1421-
return $_isSubtype(t1TypeArg, t2TypeArg, $strictMode);
1418+
// FutureOr<A> <: FutureOr<B> if A <: B
1419+
if ($_isSubtype(t1TypeArg, t2TypeArg, $strictMode)) {
1420+
return true;
1421+
}
14221422
}
14231423
14241424
// given t1 is Future<A> | A, then:

sdk_nnbd/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,10 +1413,10 @@ bool _isSubtype(t1, t2, @notNull bool strictMode) => JS<bool>('!', '''(() => {
14131413
let t1TypeArg = ${getGenericArgs(t1)}[0];
14141414
if (${_isFutureOr(t2)}) {
14151415
let t2TypeArg = ${getGenericArgs(t2)}[0];
1416-
// FutureOr<A> <: FutureOr<B> iff A <: B
1417-
// TODO(nshahan): Proven to not actually be true and needs cleanup.
1418-
// https://github.com/dart-lang/sdk/issues/38818
1419-
return $_isSubtype(t1TypeArg, t2TypeArg, $strictMode);
1416+
// FutureOr<A> <: FutureOr<B> if A <: B
1417+
if ($_isSubtype(t1TypeArg, t2TypeArg, $strictMode)) {
1418+
return true;
1419+
}
14201420
}
14211421
14221422
// given t1 is Future<A> | A, then:

0 commit comments

Comments
 (0)