Delphi Compiler Error
E2261 Implements clause only allowed for readable property
Reason for the Error & Solution
The compiler has encountered a “write only” property that claims to implement an interface. A property must be read/write to use the implements clause.
program Produce;
type
IMyInterface = interface
end;
TMyClass = class(TInterfacedObject, IMyInterface)
FMyInterface: IMyInterface;
property MyInterface: IMyInterface implements IMyInterface;
end;
end.
The property in this example is write only and cannot be used to implement an interface.
program Solve;
type
IMyInterface = interface
end;
TMyClass = class(TInterfacedObject, IMyInterface)
FMyInterface: IMyInterface;
property MyInterface: IMyInterface read FMyInterface implements IMyInterface;
end;
end.
By adding a read clause, the property can use the implements clause.