What does it mean that the E2511 Type "T" parameter must be a class type compiler error?

Following my previous question, I am trying to compile code from one of the answers.

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 do I fix the code?

+6
source share
1 answer

TObjectList<T> contains a common constraint , which T is a class. A type declaration is as follows:

 type TObjectList<T: class> = class(TList<T>) ... end; 

You might think that restrictions are inherited, but it is not. And so you need to include the restriction in your class. Set the restriction as follows:

 type TSearchableObjectList<T: class> = class(TObjectList<T>) ... end; 
+11
source

Source: https://habr.com/ru/post/949802/


All Articles