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

Unified Diff: runtime/vm/parser.cc

Issue 11419191: Enforce rule in vm that factory name must match enclosing class name. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 15422)
+++ runtime/vm/parser.cc (working copy)
@@ -2976,21 +2976,18 @@
if (IsIdentifier() &&
(CurrentLiteral()->Equals(members->class_name()) || member.has_factory)) {
if (member.has_factory) {
- // TODO(regis): Simplify this code once the core library is fixed.
- // See issue 6641.
- // Per specification, the name of the factory must be the name of the
- // immediately enclosing class.
-
- // The factory name may be qualified.
+ // The factory name may be qualified, but the first identifier must match
+ // the name of the immediately enclosing class.
QualIdent factory_name;
ParseQualIdent(&factory_name);
hausner 2012/11/28 00:26:38 Does it still make sense to use ParseQualIdent now
regis 2012/11/28 01:09:18 You are right. I simplified this code further.
member.name_pos = factory_name.ident_pos;
member.name = factory_name.ident; // Unqualified identifier.
- // The class of the factory result type is specified by the factory name.
- LibraryPrefix& lib_prefix = LibraryPrefix::Handle();
- if (factory_name.lib_prefix != NULL) {
- lib_prefix = factory_name.lib_prefix->raw();
+ if ((factory_name.lib_prefix != NULL) ||
+ !member.name->Equals(members->class_name())) {
+ ErrorMsg("factory name must be '%s'",
+ members->class_name().ToCString());
}
+ LibraryPrefix& lib_prefix = LibraryPrefix::Handle();
const Object& result_type_class = Object::Handle(
UnresolvedClass::New(lib_prefix,
*factory_name.ident,
@@ -9003,7 +9000,7 @@
}
} else {
// Factory call at runtime.
- String& factory_class_name = String::Handle(Symbols::MapImplementation());
+ String& factory_class_name = String::Handle(Symbols::Map());
const Class& factory_class =
Class::Handle(LookupCoreClass(factory_class_name));
ASSERT(!factory_class.IsNull());
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | runtime/vm/symbols.h » ('j') | tests/language/language.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698