HomeDelphiDelphi Error – E2261 Implements clause only allowed for readable property

Delphi Error – E2261 Implements clause only allowed for readable property

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.

Share:

Leave a Reply

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...