views:

111

answers:

1

I get "E2511 Type parameter 'T' must be a class type" on the third class.

type TSomeClass=class
end;

ParentParentClass<T>=class 
end;

ParentClass<T: class> = class(ParentParentClass<T>)
end;

ChildClass<T: TSomeClass> = class(ParentClass<T>)
end;

I'm trying to write a lite Generic Array wrapper for any data type(ParentParentClass) ,but because I'm unable to free type idenitifiers( if T is TObject then Tobject(T).Free) , I created the second class, which is useful for class types, so I can free the objects.

The third class is where I use my wrapper, but the compiler throws that error. How do I make it compile?

+5  A: 

This is a bug in Delphi 2009's generics handling. It was fixed in D2010.

Mason Wheeler