RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2261: Implements clause only allowed for readable property (Delphi)

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.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!