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

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
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 13204)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -1994,7 +1994,41 @@
arguments->Add(PushArgument(receiver_value.value()));
} else {
getter_function = node->cls().LookupStaticFunction(getter_name);
- ASSERT(!getter_function.IsNull());
+ if (getter_function.IsNull()) {
+ // When the parser encounters a reference to a static field materialized
+ // only by a static setter, but no corresponding static getter, it creates
+ // a StaticGetterNode ast node referring to the non-existing static getter
+ // for the case this field reference appears in a left hand side
+ // expression (the parser has not distinguished between left and right
+ // hand side yet at this stage). If the parser establishes later that the
+ // field access is part of a left hand side expression, the
+ // StaticGetterNode is transformed into a StaticSetterNode referring to
+ // the existing static setter.
+ // However, if the field reference appears in a right hand side
+ // expression, no such transformation occurs and we land here with a
+ // StaticGetterNode missing a getter function, so we throw a
+ // NoSuchMethodError.
+
+ // 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698