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

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

Issue 1803033002: Fixes #479 (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 9 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 | « tool/input_sdk/private/ddc_runtime/classes.dart ('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 ec99cf99bfe4e073de115f42bc5ff49302f4270f..069bacdc8035e81f6c2a8ccfd8a75ec13997632e 100644
--- a/tool/input_sdk/private/ddc_runtime/types.dart
+++ b/tool/input_sdk/private/ddc_runtime/types.dart
@@ -304,6 +304,13 @@ typeName(type) => JS('', '''(() => {
return "JSObject<" + $type.name + ">";
})()''');
+/// Get the underlying function type, potentially from the call method
+/// for a class type.
+getImplicitFunctionType(type) => JS('', '''(() => {
+ if ($isFunctionType($type)) return $type;
+ return $getMethodTypeFromType(type, 'call');
+})()''');
+
isFunctionType(type) => JS('', '''(() => {
return $type instanceof $AbstractFunctionType || $type == $Function;
})()''');
@@ -444,8 +451,12 @@ isSubtype_(t1, t2) => JS('', '''(() => {
}
// Function subtyping.
- // TODO(vsm): Handle Objects with call methods. Those are functions
+
+ // Handle Objects with call methods. Those are functions
// even if they do not *nominally* subtype core.Function.
+ t1 = $getImplicitFunctionType(t1);
+ if (!t1) return false;
+
if ($isFunctionType($t1) &&
$isFunctionType($t2)) {
return $isFunctionSubType($t1, $t2);
« no previous file with comments | « tool/input_sdk/private/ddc_runtime/classes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698