mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 15:47:53 +02:00
41 lines
553 B
ObjectPascal
41 lines
553 B
ObjectPascal
program tanonfunc20;
|
|
|
|
{$mode objfpc}
|
|
{$modeswitch anonymousfunctions}
|
|
{$modeswitch functionreferences}
|
|
|
|
{ test accessing parent classes across unit boundaries }
|
|
|
|
uses uanonfunc20;
|
|
|
|
type
|
|
tintfunc = reference to function: longint;
|
|
|
|
tsub = class(tbase)
|
|
y: longint;
|
|
procedure bar;
|
|
end;
|
|
|
|
procedure tsub.bar;
|
|
var
|
|
f: tintfunc;
|
|
begin
|
|
f := function: longint
|
|
begin
|
|
result := x + y;
|
|
end;
|
|
y := 456;
|
|
writeln(x, ' ', y, ' ', f());
|
|
if f() <> 579 then
|
|
halt(1);
|
|
end;
|
|
|
|
var
|
|
c: tsub;
|
|
begin
|
|
c := tsub.create;
|
|
c.bar;
|
|
c.free;
|
|
end.
|
|
|