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

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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 3103)
+++ runtime/vm/parser.cc (working copy)
@@ -2512,7 +2512,13 @@
Type& super_type = Type::Handle();
if (CurrentToken() == Token::kEXTENDS) {
ConsumeToken();
- super_type ^= ParseType(kCanResolve);
+ const AbstractType& type = AbstractType::Handle(ParseType(kCanResolve));
+ if (type.IsTypeParameter()) {
+ ErrorMsg("class '%s' may not extend type parameter '%s'",
hausner 2012/01/09 18:54:49 I would print the error at the actual text positio
regis 2012/01/09 19:19:30 Done here and on line 2523 below.
+ 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'",
class_name.ToCString(),
@@ -3004,6 +3010,17 @@
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("interface '%s' may not extend type parameter '%s'",
hausner 2012/01/09 18:54:49 Would be nice if these error messages were pointin
regis 2012/01/09 19:19:30 We should definitely store the position in each ty
+ String::Handle(cls.Name()).ToCString(),
+ String::Handle(interface.Name()).ToCString());
+ } else {
+ ErrorMsg("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)) {

Powered by Google App Engine
This is Rietveld 408576698