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?
So far as I can tell, there is no reason for the compiler to reject this code. Thus, I believe that it is a design flaw and have submitted QC#121178.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With