Index: dart/sdk/lib/_internal/lib/js_helper.dart |
diff --git a/dart/sdk/lib/_internal/lib/js_helper.dart b/dart/sdk/lib/_internal/lib/js_helper.dart |
index ba5cf5bf68c5ba31092a8d792d645a91e63fd818..2837596419a8c53f56a84724dce8f6dfb664836c 100644 |
--- a/dart/sdk/lib/_internal/lib/js_helper.dart |
+++ b/dart/sdk/lib/_internal/lib/js_helper.dart |
@@ -258,6 +258,8 @@ class CachedInvocation { |
} |
} |
+/// A "catch all" invocation is when we cannot directly call a stub. Instead, we |
+/// must extend the provided arguments with default arguments. |
class CachedCatchAllInvocation extends CachedInvocation { |
final ReflectionInfo info; |
@@ -1785,7 +1787,7 @@ abstract class Closure implements Function { |
var functionType = info.functionType; |
- // Create a closure and "monkey" patch it with call stubs. |
+ // Create a closure. |
Closure closure; |
var trampoline = function; |
if (!isStatic) { |
@@ -1819,6 +1821,7 @@ abstract class Closure implements Function { |
JS('', '#.\$signature = #', closure, signatureFunction); |
+ // "Monkey" patch the closure with call stubs. |
JS('', '#[#] = #', closure, callName, trampoline); |
for (int i = 1; i < functions.length; i++) { |
var stub = functions[i]; |
@@ -1828,6 +1831,7 @@ abstract class Closure implements Function { |
isStatic ? stub : forwardTo(receiver, stub)); |
} |
+ // Add "catch-all" stub. See [CachedCatchAllInvocation]. |
JS('', '#["call*"] = #', closure, function); |
return closure; |
@@ -2373,6 +2377,9 @@ abstract class RuntimeType { |
toRti(); |
} |
+/// Tell type inferrer it can't infer the type of [expression]. |
+obfuscate(expression) => JS('', '#', expression); |
+ |
class RuntimeFunctionType extends RuntimeType { |
final RuntimeType returnType; |
final List<RuntimeType> parameterTypes; |
@@ -2399,18 +2406,14 @@ class RuntimeFunctionType extends RuntimeType { |
} |
@NoInline() @NoSideEffects() |
- _asCheck(expression) { |
- // Type inferrer doesn't think this is called with dynamic arguments. |
- return _check(JS('', '#', expression), true); |
- } |
+ _asCheck(expression) => _check(obfuscate(expression), true); |
@NoInline() @NoSideEffects() |
_assertCheck(expression) { |
if (inAssert) return; |
inAssert = true; // Don't try to check this library itself. |
try { |
- // Type inferrer don't think this is called with dynamic arguments. |
- return _check(JS('', '#', expression), false); |
+ return _check(obfuscate(expression), false); |
} finally { |
inAssert = false; |
} |