What does the E2511 Type parameter 'T' must be a class type compiler error mean?
delphi, generics
Solution
`TObjectList<T>` includes a generic constraint that `T` is a class. The type declaration is as follows:
type
TObjectList<T: class> = class(TList<T>)
...
end;
You might think that constraints are inherited, but that is not the case. And so you need to include the constraint in your class. Specify the constraint like so:
type
TSearchableObjectList<T: class> = class(TObjectList<T>)
...
end;
Problem
Following my previous question, I am attempting to compile the code from one of the answers there. ``` type TSearchableObjectList<T> = class(TObjectList<T>) end; ``` The compiler will not compile this and reports this error message: ``` [dcc32 Error]: E2511 Type parameter 'T' must be a class type ``` What does this error message mean, and how should I fix the code?