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

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

Issue 2668543002: Fix dynamic calls on JS interop classes. (Closed)
Patch Set: 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/classes.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
index e91d790839ffbc3f9cb6bedcf6afedbd65988763..cdc14c1c37a9279066a7ac4831f04da8572ddd81 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -203,6 +203,21 @@ getType(obj) => JS(
return $obj == null ? $Object : $obj.__proto__.constructor;
})()''');
+bool isJsInterop(obj) {
+ if (JS('bool', 'typeof # === "function"', obj)) {
+ // A function is a Dart function if it has runtime type information.
+ return _getRuntimeType(obj) == null;
+ }
+ // Primitive types are not JS interop types.
+ if (JS('bool', 'typeof # !== "object"', obj)) return false;
+
+ // Extension types are not considered JS interop types.
+ // Note that it is still possible to call typed JS interop methods on
+ // extension types but the calls must be statically typed.
+ if (getExtensionType(obj) != null) return false;
+ return JS('bool', '!($obj instanceof $Object)');
+}
+
/// Get the type of a method from a type using the stored signature
getMethodType(type, name) => JS(
'',
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698