--- /dev/null
+// gcs0409.cs: A constraint clause has already been specified for type parameter `U'\r
+// Line: 7\r
+\r
+class C<T, U> where U: class, new() where U: new()\r
+{\r
+}\r
+2006-08-12 Marek Safar <marek.safar@seznam.cz>
+
+ * cs-parser.jay: Check whether a constraint clause has already been
+ specified for type parameter.
+ * generic.cs (Constraints): Exposed location.
+
2006-08-12 Marek Safar <marek.safar@seznam.cz>
* class.cs (Method.Define): Issue a warning when generic method looks like
}
| type_parameter_constraints_clauses type_parameter_constraints_clause {
ArrayList constraints = (ArrayList) $1;
+ Constraints new_constraint = (Constraints)$2;
- constraints.Add ($2);
+ foreach (Constraints c in constraints) {
+ if (new_constraint.TypeParameter == c.TypeParameter) {
+ Report.Error (409, new_constraint.Location, "A constraint clause has already been specified for type parameter `{0}'",
+ new_constraint.TypeParameter);
+ }
+ }
+
+ constraints.Add (new_constraint);
$$ = constraints;
}
;
return false;
}
+ public Location Location {
+ get {
+ return loc;
+ }
+ }
+
/// <summary>
/// This is used when we're implementing a generic interface method.
/// Each method type parameter in implementing method must have the same