- | type_parameter_constraints COMMA type_parameter_constraint {
- ArrayList constraints = (ArrayList) $1;
+ | type_parameter_constraints COMMA type_parameter_constraint
+ {
+ var constraints = (List<FullNamedExpression>) $1;
+ var prev = constraints [constraints.Count - 1] as SpecialContraintExpr;
+ if (prev != null && (prev.Constraint & SpecialConstraint.Constructor) != 0) {
+ Report.Error (401, GetLocation ($2), "The `new()' constraint must be the last constraint specified");
+ }
+
+ prev = $3 as SpecialContraintExpr;
+ if (prev != null) {
+ if ((prev.Constraint & (SpecialConstraint.Class | SpecialConstraint.Struct)) != 0) {
+ Report.Error (449, prev.Location, "The `class' or `struct' constraint must be the first constraint specified");
+ } else {
+ prev = constraints [0] as SpecialContraintExpr;
+ if (prev != null && (prev.Constraint & SpecialConstraint.Struct) != 0) {
+ Report.Error (451, GetLocation ($3), "The `new()' constraint cannot be used with the `struct' constraint");
+ }
+ }
+ }