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

Unified Diff: runtime/vm/parser.cc

Issue 10426002: Disallow repeated type parameters (issues 2239 & 2240). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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/co19/co19-runtime.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 7921)
+++ runtime/vm/parser.cc (working copy)
@@ -3142,7 +3142,9 @@
const GrowableObjectArray& bounds_array =
GrowableObjectArray::Handle(GrowableObjectArray::New());
intptr_t index = 0;
- AbstractType& type_parameter = TypeParameter::Handle();
+ TypeParameter& type_parameter = TypeParameter::Handle();
+ TypeParameter& existing_type_parameter = TypeParameter::Handle();
+ String& existing_type_parameter_name = String::Handle();
AbstractType& bound = Type::Handle();
do {
ConsumeToken();
@@ -3154,6 +3156,14 @@
index,
type_parameter_name,
token_index_);
+ // Check that the type parameter is not repeated.
+ for (intptr_t i = 0; i < index; i++) {
+ existing_type_parameter ^= type_parameters_array.At(i);
+ existing_type_parameter_name = existing_type_parameter.Name();
+ if (existing_type_parameter_name.Equals(type_parameter_name)) {
+ ErrorMsg("repeated type parameter");
+ }
+ }
ConsumeToken();
bound = Type::DynamicType();
if (CurrentToken() == Token::kEXTENDS) {
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698