Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart

Issue 2456803004: fixes #27586, prefer context type in generic inference (Closed)
Patch Set: fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
index abc476d54c70615a597a402851cb59b79606b444..63480fd29f492e335175ae27ea37441f4087f94b 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
@@ -660,11 +660,7 @@ isFunctionSubtype(ft1, ft2, isCovariant) => JS(
if (ret2 === $_void) return true;
// Dart allows void functions to subtype dynamic functions, but not
// other functions.
- // TODO(jmesserly): this check does not match our compile time subtype
- // implementation. Reconcile.
- if (ret1 === $_void) {
- return ret2 === $dynamic || ret2 === $FutureOr;
- }
+ if (ret1 === $_void) return (ret2 === $dynamic);
if (!$_isSubtype(ret1, ret2, $isCovariant)) return null;
return true;
})()''');
@@ -700,12 +696,7 @@ final isSubtype = JS(
_isBottom(type) => JS('bool', '# == #', type, bottom);
-_isTop(type) {
- if (JS('bool', '# === #', getGenericClass(type), getGenericClass(FutureOr))) {
- return _isTop(JS('', '#[0]', getGenericArgs(type)));
- }
- return JS('bool', '# == # || # == #', type, Object, type, dynamic);
-}
+_isTop(type) => JS('bool', '# == # || # == #', type, Object, type, dynamic);
_isSubtype(t1, t2, isCovariant) => JS(
'',
@@ -793,22 +784,6 @@ isClassSubType(t1, t2, isCovariant) => JS(
return true;
}
- // Handle FutureOr<T>.
- // It's not really a class type, but it's convenient to handle here.
- if (raw1 === ${getGenericClass(FutureOr)}) {
- // given t1 is Future<A> | A, then:
- // (Future<A> | A) <: t2 iff Future<A> <: t2 and A <: t2.
- let t1TypeArg = $getGenericArgs($t1)[0];
- let t1Future = ${getGenericClass(Future)}(t1TypeArg);
- return $isSubtype(t1Future, $t2) && $isSubtype(t1TypeArg, $t2);
- } else if (raw2 === ${getGenericClass(FutureOr)}) {
- // given t2 is Future<A> | A, then:
- // t1 <: (Future<A> | A) iff t1 <: Future<A> or t1 <: A
- let t2TypeArg = $getGenericArgs($t2)[0];
- let t2Future = ${getGenericClass(Future)}(t2TypeArg);
- return $isSubtype($t1, t2Future) || $isSubtype($t1, t2TypeArg);
- }
-
let indefinite = false;
function definitive(t1, t2) {
let result = $isClassSubType(t1, t2, $isCovariant);

Powered by Google App Engine
This is Rietveld 408576698