Thanks Sven :)<br><br><div class="gmail_quote">2013/3/24 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On <a href="tel:24.03.2013%2003" value="+12403201303" target="_blank">24.03.2013 03</a>:49, Xiangrong Fang wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think the problem is not fixed in 2.7.1:<br>
<br>
xrfang@laptop ~/fpc $ ./compiler/ppcx64 -n -Furtl/units/x86_64-linux<br>
-Fupackages/fcl-base/units/<u></u>x86_64-linux -viwn -FE/home/xrfang -Sc demo2.lpr<br>
Target OS: Linux for x86-64<br>
Compiling demo2.lpr<br>
Compiling treap.pas<br>
demo2.lpr(88,11) Error: Incompatible types: got "TTreap$2$crc94C56373"<br>
expected "TRoller"<br>
demo2.lpr(98) Fatal: There were 1 errors compiling module, stopping<br>
Fatal: Compilation aborted<br>
</blockquote>
<br></div>
Aha! Now that I've seen your code I know where the problem is.<br>
<br>
Your TRoller class is declared like this:<br>
<br>
=== code begin ===<br>
<br>
type<br>
TRoller = class(specialize TTreap<PPerson, Byte>)<br>
//...<br>
end;<br>
<br>
=== code end ===<br>
<br>
So TRoller is a child class of TTreap<PPerson, Byte> and thus the result type of Copy is TTreap<PPerson, Byte>. This is basically not related to generics, but to normal class inheritance. To solve this you need to adjust your TTreap.Copy in such a way that it doesn't use "TTreap.Create", but "ClassType.Create" and you must use TRoller's Copy then this way:<br>
<br>
=== code begin ===<br>
<br>
r2 := r1.Copy as TRoller;<br>
<br>
=== code end ===<div class="HOEnZb"><div class="h5"><br>
<br>
Regards,<br>
Sven<br>
______________________________<u></u>_________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.<u></u>org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/<u></u>mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br>