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

Unified Diff: runtime/vm/parser.cc

Issue 9316100: Fix for issue 1307: throw runtime exception instead of reporting a compile time error if a static... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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/bootstrap_natives.h ('k') | runtime/vm/resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 3908)
+++ runtime/vm/parser.cc (working copy)
@@ -30,6 +30,7 @@
// All references to Dart names are listed here.
static const char* kAssertionErrorName = "AssertionError";
static const char* kFallThroughErrorName = "FallThroughError";
+static const char* kStaticResolutionExceptionName = "StaticResolutionException";
static const char* kThrowNewName = "_throwNew";
static const char* kListLiteralFactoryClassName = "_ListLiteralFactory";
static const char* kListLiteralFactoryName = "List.fromLiteral";
@@ -5792,7 +5793,21 @@
closure = GenerateStaticFieldLookup(field, call_pos);
return new ClosureCallNode(call_pos, closure, arguments);
}
- ErrorMsg(ident_pos, "unresolved static method '%s'", func_name.ToCString());
+ // Could not resolve static method: throw an exception if the arguments
+ // do not match or compile time error otherwise.
+ const Function& test_func = Function::Handle(
+ Resolver::ResolveStaticByName(cls, func_name, Resolver::kIsQualified));
+ if (test_func.IsNull()) {
+ ErrorMsg(ident_pos, "unresolved static method '%s'",
+ func_name.ToCString());
+ } else {
+ ArgumentListNode* arguments = new ArgumentListNode(ident_pos);
+ arguments->Add(new LiteralNode(
+ token_index_, Integer::ZoneHandle(Integer::New(ident_pos))));
+ return MakeStaticCall(kStaticResolutionExceptionName,
+ kThrowNewName,
+ arguments);
+ }
}
CheckFunctionIsCallable(call_pos, func);
return new StaticCallNode(call_pos, func, arguments);
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698