Delphi Compiler Error
E2511 Type parameter ‘%s’ must be a class type
Reason for the Error & Solution
This occurs when the enforced type constraint on a generic type is not respected.
program E2511;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
TMyRecord = record // replace record with class to fix
end;
type
TMyData<T: class> = class(TObject)
end;
var
mustBeObjectData: TMyData<TMyRecord>; //E2511
begin
Writeln('FAIL - E2511 Type parameter ''%s'' must be a class type');
end.