From 07e292128754cfb35cdcf9ebd3f9db6c86143eb3 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Tue, 16 Jun 2020 21:20:01 +0000 Subject: [PATCH] [ddc] Cleanup false assumption from subtype check FutureOr <: FutureOr 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: https://github.com/dart-lang/sdk/issues/38818 Fixes: https://github.com/dart-lang/sdk/issues/42326 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151325 Reviewed-by: Mark Zhou Commit-Queue: Nicholas Shahan --- .../js_dev_runtime/private/ddc_runtime/types.dart | 8 ++++---- .../js_dev_runtime/private/ddc_runtime/types.dart | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart index 48d54adcb91..625e44f9cb3 100644 --- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart +++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart @@ -1415,10 +1415,10 @@ bool _isSubtype(t1, t2, @notNull bool strictMode) => JS('!', '''(() => { let t1TypeArg = ${getGenericArgs(t1)}[0]; if (${_isFutureOr(t2)}) { let t2TypeArg = ${getGenericArgs(t2)}[0]; - // FutureOr <: FutureOr iff A <: B - // TODO(nshahan): Proven to not actually be true and needs cleanup. - // https://github.com/dart-lang/sdk/issues/38818 - return $_isSubtype(t1TypeArg, t2TypeArg, $strictMode); + // FutureOr <: FutureOr if A <: B + if ($_isSubtype(t1TypeArg, t2TypeArg, $strictMode)) { + return true; + } } // given t1 is Future | A, then: diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart index 41cc31d77c9..f5f25a0cc46 100644 --- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart +++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart @@ -1413,10 +1413,10 @@ bool _isSubtype(t1, t2, @notNull bool strictMode) => JS('!', '''(() => { let t1TypeArg = ${getGenericArgs(t1)}[0]; if (${_isFutureOr(t2)}) { let t2TypeArg = ${getGenericArgs(t2)}[0]; - // FutureOr <: FutureOr iff A <: B - // TODO(nshahan): Proven to not actually be true and needs cleanup. - // https://github.com/dart-lang/sdk/issues/38818 - return $_isSubtype(t1TypeArg, t2TypeArg, $strictMode); + // FutureOr <: FutureOr if A <: B + if ($_isSubtype(t1TypeArg, t2TypeArg, $strictMode)) { + return true; + } } // given t1 is Future | A, then: