mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 14:48:18 +02:00

the scope penalty relative to the nearest symtable that contains one of the applicable overloads, rather than relative to the nearest symtable that simply contains a method with this name (based on patch by Maciej Izak, mantis #25607) git-svn-id: trunk@35089 -
65 lines
1.2 KiB
ObjectPascal
Executable File
65 lines
1.2 KiB
ObjectPascal
Executable File
program E01;
|
|
|
|
{$IFDEF FPC}
|
|
{$MODE DELPHI}
|
|
{$ENDIF}
|
|
{$APPTYPE CONSOLE}
|
|
|
|
type
|
|
TA = class
|
|
constructor Create(A: Integer = 0); overload; virtual;
|
|
end;
|
|
|
|
TB = class(TA)
|
|
constructor Create(A: Integer); overload; override;
|
|
end;
|
|
|
|
TClassB = class of TB;
|
|
|
|
var
|
|
tacalled,
|
|
tbcalled: boolean;
|
|
|
|
constructor TA.Create(A: Integer = 0);
|
|
begin
|
|
WriteLn('TA.Create');
|
|
tacalled:=true;
|
|
end;
|
|
|
|
constructor TB.Create(A: Integer);
|
|
begin
|
|
WriteLn('TB.Create');
|
|
tbcalled:=true;
|
|
end;
|
|
|
|
var
|
|
B: TB;
|
|
ClassB: TClassB;
|
|
begin
|
|
B := TB.Create; // TA.Create (VMT is not used
|
|
// compiler can determine) -- in Delphi;
|
|
// In FPC, because TB.Create is used, we
|
|
// call TB.Create
|
|
if tacalled then
|
|
halt(1);
|
|
if not tbcalled then
|
|
halt(2);
|
|
tbcalled:=false;
|
|
|
|
B.Create; // call TB.Create because of VMT rules
|
|
B.Free;
|
|
if tacalled then
|
|
halt(3);
|
|
if not tbcalled then
|
|
halt(4);
|
|
tbcalled:=false;
|
|
|
|
ClassB := TB;
|
|
B := ClassB.Create; // call TB.Create because of VMT rules
|
|
B.Free;
|
|
if tacalled then
|
|
halt(5);
|
|
if not tbcalled then
|
|
halt(6);
|
|
end.
|