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

Unified Diff: runtime/lib/mirrors.cc

Issue 21430002: Allow InstanceMirror.invoke to find private members. Resolves issue 11771. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | tests/lib/mirrors/invoke_private_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
===================================================================
--- runtime/lib/mirrors.cc (revision 25684)
+++ runtime/lib/mirrors.cc (working copy)
@@ -13,7 +13,6 @@
#include "vm/message.h"
#include "vm/object_store.h"
#include "vm/port.h"
-#include "vm/resolver.h"
#include "vm/symbols.h"
#include "lib/invocation_mirror.h"
@@ -733,12 +732,22 @@
ArgumentsDescriptor args_desc(
Array::Handle(ArgumentsDescriptor::New(args.Length())));
- // TODO(11771): This won't find private members.
- const Function& function = Function::Handle(
- Resolver::ResolveDynamic(reflectee,
- function_name,
- args_desc));
+ Class& klass = Class::Handle(reflectee.clazz());
+ Function& function = Function::Handle();
+ while (!klass.IsNull()) {
+ function = klass.LookupDynamicFunctionAllowPrivate(function_name);
+ if (!function.IsNull()) {
+ break;
+ }
+ klass = klass.SuperClass();
+ }
+
+ if (!function.IsNull() &&
+ !function.AreValidArguments(args_desc, NULL)) {
+ function = Function::null();
+ }
+
return ReflectivelyInvokeDynamicFunction(reflectee,
function,
function_name,
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | tests/lib/mirrors/invoke_private_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698