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

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

Issue 2827333003: Tighten up handling of JS types and add test. (Closed)
Patch Set: Tighten up handling of JS types. Fix bug where helpers in js_mirrors were specifying name had type … Created 3 years, 8 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/operations.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
index 5299374ca4c7a8c8b2feb2136cd40eca1b1416ac..35f706be3f519ac02247376421c8a99dcc4d41b0 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
@@ -439,6 +439,7 @@ final _ignoreTypeFailure = JS(
})()''');
/// Returns true if [obj] is an instance of [type]
+/// Returns true if [obj] is a JS function and [type] is a function type
/// Returns false if [obj] is not an instance of [type] in both spec
/// and strong mode
/// Returns null if [obj] is not an instance of [type] in strong mode
@@ -448,8 +449,8 @@ bool strongInstanceOf(obj, type, ignoreFromWhiteList) => JS(
'''(() => {
let actual = $getReifiedType($obj);
let result = $isSubtype(actual, $type);
- if (result || actual == $jsobject ||
- (actual == $int && $isSubtype($double, $type))) return true;
+ if (result || (actual == $int && $isSubtype($double, $type))) return true;
+ if (actual == $jsobject && $isFunctionType(type) && typeof(obj) === 'function') return true;
vsm 2017/04/21 12:35:58 nit: line len
if (result === false) return false;
if (!$_ignoreWhitelistedErrors || ($ignoreFromWhiteList == void 0)) return result;
if ($_ignoreTypeFailure(actual, $type)) return true;

Powered by Google App Engine
This is Rietveld 408576698