It’s impossible to access a property/method of a class when the class implements the interface via a property and the instance variable is not of the type of the interface but the class itself.
See the following example, which fails to compile with:
Severity Code Description Project File Line Suppression State
Error (E44) No member "Vgid" on type "TestTypeWrapper" ImplementsTest ImplementsTest\ImplementsTest\Program.pas 53
Error (E44) No member "Vgid" on type "TestTypeWrapper" ImplementsTest ImplementsTest\ImplementsTest\Program.pas 50
Code:
namespace ImplementsTest;
interface
uses
System.Linq;
type
Program = class
public
class method Main(args: array of String): Int32;
end;
implementation
type
ITestType = interface
property Vgid: String read write;
end;
type
TestType = class(ITestType)
public
property Vgid: String;
end;
type
TestTypeWrapper = class(ITestType)
protected
fTestType: ITestType;
property TestType: ITestType read fTestType; implements ITestType;
public
constructor;
end;
constructor TestTypeWrapper;
begin
fTestType := new TestType;
end;
class method Program.Main(args: array of String): Int32;
begin
var t1 := new TestType;
t1.Vgid := "AAA";
var t2: ITestType := new TestTypeWrapper;
t2.Vgid := "AAA";
var t3 := new TestTypeWrapper;
t3.Vgid := "AAA";
var t4: TestTypeWrapper := new TestTypeWrapper;
t4.Vgid := "AAA";
end;
end.
But TestTypeWrapper implements ITestType and therefore I think it should have a Vgid property, even when it is internally accessible via TestType.