{$APPTYPE CONSOLE}
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}

type

PB = ^B;
B = object
    public
    test: string;

    constructor Init;

    function GetTest: string;
end;

PA = ^A;
A = object
    public
    function TestFunc: string;
end;

function A.TestFunc;
begin
    Writeln('>> this.test = ', PB(@self)^.test);
    Result := PB(@self)^.test
end;

constructor B.init;
begin
    self.test := 'Nice trick';
end;

function B.GetTest;
begin
    Result := PA(@self)^.TestFunc;
end;

var theb: PB;
begin
    theb := new(PB, Init);
    Writeln(theb^.GetTest())
end.
