[fpc-devel] Black List of examples that FPC won't compile.
DrDiettrich1 at aol.com
Wed Jan 29 08:10:59 CET 2014
Maciej Izak schrieb:
> Following by current logic, this example should not compile:
> ------begin code------
> TA = class
> procedure Foo;
> TB = class(TA)
> procedure Foo(A: Integer = 0); overload;
> b: TB;
> b := TB.Create;
> b.Foo; // should raise Error: Can't determine which overloaded
> function to call
> ------end code------
Delphi (XE) has no problem with this code, even if TA.Foo also is
declared "overload", or both are declared Foo(). The static type (b:TB)
determines which static method to call.
> Returning to the example from bugtracker
> FPC don't recognize at TB level that the TObject.Create was hidden on
> the TA level by
> constructor Create(A: Integer = 0); virtual; overload;
Delphi here requires
constructor Create(A: Integer = 0); overload; virtual;
Delphi seems to search for overloaded methods only in the same class.
Otherwise an error "Previous declaration ... not marked 'overload'"
would occur since TObject.Create was not marked 'overload'. Tested with
declarations in the same class:
constructor Create(A: integer);
where *both* must be marked 'overload'.
Only if there is no matching method in a class, the ancestors are
searched as well. I.e. Delphi does not *hide* inherited methods, it only
extends the search into ancestors *when required*, regardless of
More information about the fpc-devel