Send virtual overload and overriden method as parameter of procedure
Original Reporter info from Mantis: bork
-
Reporter name: Boris Matkov
Original Reporter info from Mantis: bork
- Reporter name: Boris Matkov
Description:
Tested with FPC 2.4.2 because it is included into the last Lazarus Snapshot.
Declaration:
{$MODE DELPHI}
type
TExecProc = procedure of object;
TA = class
public
procedure P1; overload; virtual;
procedure P1(const param: boolean); overload; virtual;
end;
TB = class(TA)
public
procedure P1(const param: boolean); override;
end;
procedure ShowProc(p: TExecProc);
Implementation:
procedure ShowProc(p: TExecProc);
begin
p;
end;
procedure TA.P1;
begin
ShowMessage('1');
end;
procedure TA.P1(const param: boolean);
begin
ShowMessage('2');
end;
procedure TB.P1(const param: boolean);
begin
ShowMessage('3');
end;
Calling:
var
a: TA;
b: TB;
begin
a := TA.Create;
b := TB.Create;
ShowProc(a.P1); // compile and execute correctly
ShowProc(b.P1); // error on compile !!! but here should be call TA.P1 !!!
end;
Mantis conversion info:
- Mantis ID: 18706
- Version: 2.4.2
- Fixed in version: 2.6.1
- Fixed in revision: 20427 (#75aac428)