Delphi Error – E2549 Cannot declare parameterized type derived from custom attribute class

Delphi Compiler Error

E2549 Cannot declare parameterized type derived from custom attribute class

Reason for the Error & Solution

This error occurs when using a parameterized type that inherits from TCustomAttribute.

program GenericAttributes;

{$APPTYPE CONSOLE}

type
  AttrAttribute<T> = class(TCustomAttribute)
  end;

  [Attr<Byte>]
  TNew = type Integer;

begin
end.

See Also