[fpc-devel] override works, even if result type changed?
flavio.etrusco at gmail.com
Sun Feb 23 19:31:51 CET 2014
On Sun, Feb 23, 2014 at 1:56 PM, Martin Frb <lazarus at mfriebe.de> 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;
> TFoo= class
> function a: TFoo; virtual;
> TFoo2= class(TFoo)
> function a: TFoo2; override;
> function TFoo2.a: TFoo2;
> function TFoo.a: TFoo;
I hope so :) 
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...)
More information about the fpc-devel