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

Unified Diff: runtime/vm/parser.cc

Issue 13992002: Prohibit use of dynamic when extending or implementing classes (was crashing). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/class_finalizer.cc ('k') | tests/language/dynamic2_test.dart » ('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 21216)
+++ runtime/vm/parser.cc (working copy)
@@ -3071,14 +3071,19 @@
ErrorMsg(member.name_pos, "factory name must be '%s'",
members->class_name().ToCString());
}
+ // Do not bypass class resolution by using current_class() directly, since
+ // it may be a patch class.
const Object& result_type_class = Object::Handle(
UnresolvedClass::New(LibraryPrefix::Handle(),
*member.name,
member.name_pos));
- // The type arguments of the result type are set during finalization.
- member.type = &Type::ZoneHandle(Type::New(result_type_class,
- TypeArguments::Handle(),
- member.name_pos));
+ // The type arguments of the result type are the type parameters of the
+ // current class. Note that in the case of a patch class, they are copied
+ // from the class being patched.
+ member.type = &Type::ZoneHandle(Type::New(
+ result_type_class,
+ TypeArguments::Handle(current_class().type_parameters()),
+ member.name_pos));
} else if (member.has_static) {
ErrorMsg(member.name_pos, "constructor cannot be static");
}
@@ -3301,6 +3306,11 @@
class_name.ToCString(),
String::Handle(super_type.UserVisibleName()).ToCString());
}
+ if (super_type.IsDynamicType()) {
+ ErrorMsg(type_pos,
+ "class '%s' may not extend 'dynamic'",
+ class_name.ToCString());
+ }
if (CurrentToken() == Token::kWITH) {
super_type = ParseMixins(super_type);
}
@@ -3842,6 +3852,9 @@
"type parameter '%s' may not be used in interface list",
String::Handle(interface.UserVisibleName()).ToCString());
}
+ if (interface.IsDynamicType()) {
+ ErrorMsg(interface_pos, "'dynamic' may not be used in interface list");
+ }
all_interfaces.Add(interface);
} while (CurrentToken() == Token::kCOMMA);
cls_interfaces = Array::MakeArray(all_interfaces);
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/language/dynamic2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698