[fpc-devel] suggestion: virtual method co-variance

Sven Barth pascaldragon at googlemail.com
Wed Oct 15 07:44:27 CEST 2014


On 14.10.2014 15:34, Jonas Maebe wrote:
>
> On 14 Oct 2014, at 14:21, Sven Barth wrote:
>
>> At least at first sight there don't seem to be any real (technical)
>> reasons
>> to not covariance for return values.
>
> Delphi and/or FPC already support it to a certain extent, and the
> compiler contains some code for it (see compatible_childmethod_resultdef
> in defcmp.pas and its use in nobj.pas). I don't know the exact scenario
> under which it currently works in though.

I just tested my example code (filled in the holes I left of course) and 
it works. So... we already have covariance support for result types! ;)

Regards,
Sven




More information about the fpc-devel mailing list