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

Unified Diff: runtime/vm/parser.cc

Issue 9153006: A class/interface cannot implement/extend a type parameter (issues 886 and 887). (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 | « no previous file | tests/language/language.status » ('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 3121)
+++ runtime/vm/parser.cc (working copy)
@@ -2512,9 +2512,18 @@
Type& super_type = Type::Handle();
if (CurrentToken() == Token::kEXTENDS) {
ConsumeToken();
- super_type ^= ParseType(kCanResolve);
+ const intptr_t type_pos = token_index_;
+ const AbstractType& type = AbstractType::Handle(ParseType(kCanResolve));
+ if (type.IsTypeParameter()) {
+ ErrorMsg(type_pos,
+ "class '%s' may not extend type parameter '%s'",
+ class_name.ToCString(),
+ String::Handle(type.Name()).ToCString());
+ }
+ super_type ^= type.raw();
if (super_type.IsInterfaceType()) {
- ErrorMsg("class '%s' may implement, but cannot extend interface '%s'",
+ ErrorMsg(type_pos,
+ "class '%s' may implement, but cannot extend interface '%s'",
class_name.ToCString(),
String::Handle(super_type.Name()).ToCString());
}
@@ -3004,6 +3013,19 @@
for (intptr_t i = 0; i < interfaces.Length(); i++) {
AbstractType& interface = AbstractType::ZoneHandle();
interface ^= interfaces.At(i);
+ if (interface.IsTypeParameter()) {
+ if (cls.is_interface()) {
+ ErrorMsg(interfaces_pos,
+ "interface '%s' may not extend type parameter '%s'",
+ String::Handle(cls.Name()).ToCString(),
+ String::Handle(interface.Name()).ToCString());
+ } else {
+ ErrorMsg(interfaces_pos,
+ "class '%s' may not implement type parameter '%s'",
+ String::Handle(cls.Name()).ToCString(),
+ String::Handle(interface.Name()).ToCString());
+ }
+ }
if (!ClassFinalizer::AddInterfaceIfUnique(&all_interfaces,
&interface,
&conflicting)) {
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698