[fpc-pascal] class inheritance and type incompatibility
Sven Barth
pascaldragon at googlemail.com
Thu Sep 26 17:31:42 CEST 2013
On 26.09.2013 16:42, Xiangrong Fang wrote:
> What should work is the following (now with generics again):
>
> === code begin ===
>
> type
> TTree<T> = class
> private type
> TSelfClass = class of TTree;
> public
> function Clone: TTree;
> end;
>
> function TTree.Clone: TTree;
> begin
> Result := TSelfClass(Self.ClassType).__Create(Data, FParent);
> (* ... *)
> end;
>
> After change to this code in Clone(), I got this error:
>
>
> tree.pas(66,60) Error: Incompatible type for arg no. 2: Got
> "TIntTree.TTree$LongInt", expected "TTree"
Seems like a bug in 2.6.x. It's compiling in 2.7.1.
Regards,
Sven
More information about the fpc-pascal
mailing list