Delphi Error – W1009 Redeclaration of ‘%s’ hides a member in the base class

Delphi Compiler Error

W1009 Redeclaration of ‘%s’ hides a member in the base class

Reason for the Error & Solution

A property has been created in a class with the same name of a variable contained in one of the base classes. One possible, and not altogether apparent, reason for getting this error is that a new version of the base class hierarchy has been installed and it contains new member variables which have names identical to your properties’ names. -W

(*$WARNINGS ON*)
program Produce;

  type
    Base = class
      v : integer;
    end;

    Derived = class (Base)
      ch : char;
      property v : char read ch write ch;
    end;

begin
end.

Derived.v overrides, and thus hides, Base.v; it will not be possible to access Base.v in any variable of type Derived without a typecast.

(*$WARNINGS ON*)
program Solve;
  type
    Base = class
      v : integer;
    end;

    Derived = class (Base)
      ch : char;
      property chV : char read ch write ch;
    end;

begin
end.

By changing the name of the property in the derived class, the error is alleviated.

See Also

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...