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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 14646031: Implement invoke, setField, and getField (unminified). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 7 years, 7 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: 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].

Powered by Google App Engine
This is Rietveld 408576698