akarigar
2014-11-20 18:02:51
The following example incorrectly calls TObj.test, @Brandon also thinks this is a bug.
From: Brandon
It's not possible. Lape is broken afaict. The example you gave SHOULD be working. The object is being sliced and the inheritance isn't virtual either: http://en.wikipedia.org/wiki/Object_slicing
type
PObj = ^TObj;
TObj = record
i: integer;
end;
type TComplexObj = record(TObj)
s: string;
end;
procedure TObj.test();
begin
writeLn('TObj.test(): ', self.i);
end;
procedure TComplexObj.test(); override;
begin
inherited();
writeLn('TComplexObj.test(): ', self.i, ' & ', self.s);
end;
procedure callTest(obj: PObj);
begin
obj^.test();
end;
var o: TComplexObj;
begin
o.i := 131;
o.s := 'yes!';
callTest(@o);
end.