+2
Planned
Request Warning: class field hides a class field of parent class
I don't know if it possible for FixInsight to detect his, but here is my use case.
I have two classes, TParent and TChild, and a class field in TChild hides a class field defined in TParent.
I have two classes, TParent and TChild, and a class field in TChild hides a class field defined in TParent.
unit FixInsightTest;
interface
uses
SysUtils,
Classes;
type
TParent = class(TPersistent)
private
fPrivate: string;
protected
fProtected: string;
public
fPublic: string;
end;
TChild = class(TParent)
private
fPrivate: string; // this is fine, since it's private for this class
protected
fProtected: string; // class field hides class field of parent class
public
fPublic: string; // class field hides class field of parent class
end;
//
// Tested with FixInsight 2015.04
//
// This is somehow related to the warning W517, but this is a special case
// because the current class' field hides a field of the parent class
//
// "W517 Variable '%s' hides a class field, method or property"
//
implementation
end.
0
Planned
Roman 10 years ago
0
Vincent Parrett 10 years ago
Would like to see this extended to properties as well.. just had a case where a property and it's backing field was redeclared in a descendant class, both inside a package.. no compiler warnings issues and fix insight didn't find it. Caused a serialization issue (rtti for reading found he base class field, writing the descendant! Doh!).
Customer support service by UserEcho