Delphi Compiler Error
E2603 Constraint ‘%s’ cannot be specified more than once
Reason for the Error & Solution
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.