E2603 Constraint '%s' cannot be specified more than once (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)


This occurs whenever you try to specify a generics constraint more than once.

type
  TFoo<T: constructor, constructor> = class // issues error: E2603 'constructor'
  end;
  TBar<T: class, class> = class             // issues error: E2603 'class'
  end;
  TBaz<T: record, record> = class           // issues error: E2603 'record'
  end;
end.

This can be solved by removing the extra constraint:

type
  TFooOK<T: constructor> = class // OK
  end;
  TBarOK<T: class> = class       // OK
  end;
  TBazOK<T: record> = class      // OK
  end;
end.

See Also