Isn't GetTypeKind evaluated at compile time? I'd love to write this:

Isn't GetTypeKind evaluated at compile time? I'd love to write this:

function TFoo.Bar: IEnumerable
begin
if OwnsObjects and (System.GetTypeKind(T) = TTypeKind.tkClass) then
AList:= TCollections.CreateObjectList
else
AList := TCollections.CreateList;

...
end;

This fails to compile with a "[dcc32 Error] E2511 Type parameter 'T' must be a class type"

Of course the generic T is not constrained as T: class, because I want to support both primitive and class types

Comments