Index: dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
index 290385f39c36313e745f62de91c45ccabb0328f4..c9c331de4870364eafb32e576f7c5f346cf6db6d 100644 |
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
@@ -133,7 +133,15 @@ class JSInvocationMirror implements Invocation { |
arguments = [object]..addAll(arguments); |
receiver = interceptor; |
} |
- return JS("var", "#[#].apply(#, #)", receiver, name, receiver, arguments); |
+ var method = JS('var', '#[#]', receiver, name); |
+ if (JS('String', 'typeof #', method) == 'function') { |
+ return JS("var", "#.apply(#, #)", method, receiver, arguments); |
+ } else { |
+ // In this case, receiver doesn't implement name. So we should |
+ // invoke noSuchMethod instead (which will often throw a |
+ // NoSuchMethodError). |
+ return receiver.noSuchMethod(this); |
+ } |
} |
/// This method is called by [InstanceMirror.delegate]. |