0
Fixed
[W527] False positive
W527 returns a false positive when an encapsulated object with the same property name is accessed in the getter/setter.
Example:
Example:
TMyObj = class
private
FSubObject : TSubObject;
function GetText: String;
public
property Text:string read GetText;
end;
function TMyObj.GetText: String;
begin
try
Result := FSubObject.Text
except
Result := 'Not Assigned';
end
end;Customer support service by UserEcho
Should fix this in my code :)
The convention would be that the getter/setter name = Get<propertyname>/Set<propertyname>
On FixInsight 2016.03, this problem seems to be reproduced. See below codes.
unit Unit2;
interface
uses
System.Generics.Collections;
type
TChild = class(TObject)
end;
TChildList = TObjectList<TChild>;
TParent = class(TObject)
private
FChildList: TObjectList<TChild>;
function GetItems(Index: Integer): TChild;
public
constructor Create;
destructor Destroy; override;
property Items[Index: Integer]: TChild read GetItems;
end;
implementation
constructor TParent.Create;
begin
inherited;
FChildList := TObjectList<TChild>.Create(True);
end;
destructor TParent.Destroy;
begin
FChildList.Free;
inherited;
end;
function TParent.GetItems(Index: Integer): TChild;
begin
Result := FChildList.Items[Index]; // W527 Property access in getter or setter
// Result := FChildList[Index]; // OK
end;
end.
On FixInsight 2016.04, W527 false positive problem is resolved. Thank you.
in FixInsight 2016.03 I still get a similar warning:
function TGrepHistoryList.GetItems(AIndex: Integer): TGrepHistoryListItem;
That's a false positive FHistoryList[].Items is not the property to which GetItems is the getter.