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

Unified Diff: runtime/vm/mirrors_api_impl.cc

Issue 19662003: Refactor resolution code in the vm to properly handle ambiguity errors. (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 | « runtime/vm/intrinsifier_x64.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/mirrors_api_impl.cc
===================================================================
--- runtime/vm/mirrors_api_impl.cc (revision 25321)
+++ runtime/vm/mirrors_api_impl.cc (working copy)
@@ -342,22 +342,27 @@
const Library& lib = Library::Cast(obj);
// Case 1. Lookup the unmodified function name.
- func = lib.LookupFunctionAllowPrivate(func_name);
+ String& ambiguity_error_msg = String::Handle(isolate);
+ func = lib.LookupFunctionAllowPrivate(func_name, &ambiguity_error_msg);
// Case 2. Lookup the function without the external setter suffix
// '='. Make sure to do this check after the regular lookup, so
// that we don't interfere with operator lookups (like ==).
- if (func.IsNull() && HasExternalSetterSuffix(func_name)) {
+ if (func.IsNull() && ambiguity_error_msg.IsNull() &&
+ HasExternalSetterSuffix(func_name)) {
tmp_name = RemoveExternalSetterSuffix(func_name);
tmp_name = Field::SetterName(tmp_name);
- func = lib.LookupFunctionAllowPrivate(tmp_name);
+ func = lib.LookupFunctionAllowPrivate(tmp_name, &ambiguity_error_msg);
}
// Case 3. Lookup the function with the getter prefix prepended.
- if (func.IsNull()) {
+ if (func.IsNull() && ambiguity_error_msg.IsNull()) {
tmp_name = Field::GetterName(func_name);
- func = lib.LookupFunctionAllowPrivate(tmp_name);
+ func = lib.LookupFunctionAllowPrivate(tmp_name, &ambiguity_error_msg);
}
+ if (!ambiguity_error_msg.IsNull()) {
+ return Api::NewError("%s.", ambiguity_error_msg.ToCString());
+ }
} else {
return Api::NewError(
"%s expects argument 'target' to be a class or library.",
@@ -664,7 +669,13 @@
}
if (obj.IsLibrary()) {
const Library& lib = Library::Cast(obj);
- return Api::NewHandle(isolate, lib.LookupFieldAllowPrivate(var_name));
+ String& ambiguity_error_msg = String::Handle(isolate);
+ const Field& variable = Field::Handle(
+ lib.LookupFieldAllowPrivate(var_name, &ambiguity_error_msg));
+ if (!ambiguity_error_msg.IsNull()) {
+ return Api::NewError("%s.", ambiguity_error_msg.ToCString());
+ }
+ return Api::NewHandle(isolate, variable.raw());
}
return Api::NewError(
"%s expects argument 'target' to be a class or library.",
« no previous file with comments | « runtime/vm/intrinsifier_x64.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698