E2511 Type parameter '%s' must be a class type (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

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.