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

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

Issue 1958683002: Fix void subtype checks. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « test/browser/runtime_tests.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/ddc_runtime/types.dart
diff --git a/tool/input_sdk/private/ddc_runtime/types.dart b/tool/input_sdk/private/ddc_runtime/types.dart
index 8c0f09a74192afb5844328748d8f3f8aa728cf77..1cecf25f925d68b189ebd3d050f41269283ca556 100644
--- a/tool/input_sdk/private/ddc_runtime/types.dart
+++ b/tool/input_sdk/private/ddc_runtime/types.dart
@@ -431,22 +431,13 @@ isFunctionSubtype(ft1, ft2, covariant) => JS('', '''(() => {
// Check return type last, so that arity mismatched functions can be
// definitively rejected.
- {
- let result = $isSubtype_(ret1, ret2, $covariant);
- if (result === null) return result;
- if (!result) {
- // Covariant return types
- // Note, void (which can only appear as a return type) is effectively
- // treated as dynamic. If the base return type is void, we allow any
- // subtype return type.
- // E.g., we allow:
- // () -> int <: () -> void
- if (ret2 !== $voidR) {
- return null;
- }
- }
- }
+ // We allow any type to subtype a void return type, but not vice versa
+ if (ret2 === $voidR) return true;
+ // Dart allows void functions to subtype dynamic functions, but not
+ // other functions.
+ if (ret1 === $voidR) return (ret2 === $dynamicR);
+ if (!$isSubtype_(ret1, ret2, $covariant)) return null;
return true;
})()''');
« no previous file with comments | « test/browser/runtime_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698