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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 11049038: Change compile-time errors into dynamic errors in instance creation expression (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 13198)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -1994,7 +1994,31 @@
arguments->Add(PushArgument(receiver_value.value()));
} else {
getter_function = node->cls().LookupStaticFunction(getter_name);
- ASSERT(!getter_function.IsNull());
+ if (getter_function.IsNull()) {
+ // A StaticGetterNode without a function is created by the parser when
+ // a corresponding setter exists so that the getter can be transformed
+ // into the setter. In this case, the fake getter was not transformed into
+ // a setter, so we throw a NoSuchMethodError.
srdjan 2012/10/03 23:28:03 The comment is not very clear.
regis 2012/10/04 00:12:23 I tried to improve it.
+ // Location argument.
+ Value* call_pos = Bind(
+ new ConstantInstr(Smi::ZoneHandle(Smi::New(node->token_pos()))));
+ arguments->Add(PushArgument(call_pos));
+ // Function name argument.
+ const String& method_name = String::ZoneHandle(Symbols::New(getter_name));
+ Value* method_name_value = Bind(new ConstantInstr(method_name));
+ arguments->Add(PushArgument(method_name_value));
+ const String& cls_name = String::Handle(Symbols::NoSuchMethodError());
+ const String& func_name = String::Handle(Symbols::ThrowNew());
+ const Class& cls = Class::Handle(
+ Library::Handle(Library::CoreImplLibrary()).LookupClass(cls_name));
+ ASSERT(!cls.IsNull());
+ getter_function = Resolver::ResolveStatic(cls,
+ func_name,
+ arguments->length(),
+ Array::ZoneHandle(),
+ Resolver::kIsQualified);
+ ASSERT(!getter_function.IsNull());
+ }
}
StaticCallInstr* call = new StaticCallInstr(node->token_pos(),
getter_function,
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698