I noticed a strange bug with the TVirtualInterface class. I tried something like following :
ITest1 = interface
procedure Test1();
End;
ITest2 = Interface(ITest1)
procedure Test2();
End;
ITest3 = Interface(ITest2)
procedure Test3();
ENd;
procedure Test();
var
test : ITest3;
begin
test := TVirtualInterface(TypeInfo(ITest3),
procedure(Method: TRttiMethod;
const Args: TArray<TValue>; out Result: TValue)
begin
showMessage(Method.Name);
end) as ITest3;
test.test1();
test.test2();
test.test3();
End;
The code above works fine. If i change it like this :
ITest3 = Interface(ITest2)
procedure Test3();
function GetLabel : string;
property Label : string read GetLabel;
ENd;
and i call :
showmessage(test.Label);
... it still works.
But if i move this property to ITest2 or ITest1, calls to some methods of any of ITest1, ITest2 or ITest3 will either call the wrong method (for example test.Test2() will display "Test3"), either crash (access violation).
Any explanation and/or fix to this ?
Edit >> Sorry, actually it actually seems to fail only with properties of the kind :
property Item[Name : string] : X read GetX write SetX;