On Sun, Feb 23, 2014 at 1:56 PM, Martin Frb <[email protected]> wrote:
> Just found that the below works.
>
> Note, that the result type of "a" (overridden) is different.
> Well, TFoo2 will always satisfy the needs of TFoo, so it seems save. I still
> found it surprising. Is it intended?
>
>
> program Project1;
> type
>   TFoo= class
>   public
>     function a: TFoo; virtual;
>   end;
>
>   TFoo2= class(TFoo)
>   public
>     function a: TFoo2; override;
>   end;
>
> function TFoo2.a: TFoo2;
> begin
> end;
>
> function TFoo.a: TFoo;
> begin
> end;
>
> begin
> end.
>

I hope so :) [1]
But it seems (from a 2011 blog) Delphi still doesn't allow that?
I wouldn't mind fpc allowed contravariant arguments too ;) (But I
guess I only ever missed it once or twice...)

Regards,
Flávio

[1] 
http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to