Am 30.09.2013 04:10 schrieb "Xiangrong Fang" <xrf...@gmail.com>:
>
> 2013/9/30 Sven Barth <pascaldra...@googlemail.com>
>>
>>
>>> However, this does not work, because it seems that I cannot make any
>>> generic method virtual!  In TIntTree, I have to write:
>>>
>>> function TIntTree.DoClone: TIntTree;
>>>
>>> As it is not possible to write TTree outside of the generic definition.
>>
>>
>> This should do it:
>
>
> Right, this worked. My last question for this issue: is the TSelfType a
2.6.2 workaround, or it is required even in 2.7.1? I mean, how about this:
>
> === code ===
> type
>   generic TTree = class
>   protected
>     procedure DoClone(aNode: TTree); virtual;  //<<-- instead of TSelfType
>   end;
>   TIntTree = class(specialize TTree<Integer)
>   protected
>     procedure DoClone(aNode: TTree); override; //<<-- instead of TSelfType
>   end;
> === end code ===
>
> In another word, use "TTree" to represent any of its specialization and
their descendants. Is it possible in 2.7.1 or later?

You don't require "TSelfType" in 2.7.1, but the correct one is not "TTree",
but "specialize TTree<Integer>". If "TTree" should work then that's a bug...

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to