Why is class of T not allowed in a generic type?

Viewed 1228

Consider this program:

type
  TMyClass<T: class> = class
  public type
    TClassOfT = class of T;
  end;

begin
end.

This fails to compile at the declaration of TClassOfT with the error message:

E2021 Class type required

Can anyone explain why this is so? If I were to instantiate this class with, for instance TMyClass<TObject> then surely class of TObject would be meaningful. I constrained the generic parameter to be a class. So how can the compiler object that T is not a class type?

1 Answers
Related