Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Class Completion    [ Add a report in this area ]  
Report #:  94022   Status: Open
Class completion error when using inherited methods in properties
Project:  Delphi Build #:  35171
Version:    15.1 Submitted By:   Ritsaert Hornstra
Report Type:  Minor failure / Design problem Date Reported:  5/18/2011 1:59:01 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 3:49:15 AM
Platform:    All platforms Internal Tracking #:   26508
Resolution: Duplicate (Resolution Comments) Resolved in Build: : None
Duplicate of:  11227
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
When a base class has some methods (like in the steps a getter/setter) and in a derived class you create a propertry to access those methods (in the example with a specified index). Now when in the derived class you use class compeltion the used methods are introduced again!
Steps to Reproduce:
-- Create a unit with:

unit Unit1;

interface

type
  TBase = class
  protected
    FInts: array [ 0..1 ] of Integer;
    function GetInt(Index: Integer): Integer;
    procedure SetInt(Index: Integer; const Value: Integer);
  public
    property Ints[ Index: Integer ]: Integer read GetInt write SetInt;
  end;

implementation

{ TBase }

function TBase.GetInt(Index: Integer): Integer;
begin
  Result := FInts[ Index ];
end;

procedure TBase.SetInt(Index: Integer; const Value: Integer);
begin
  FInts[ Index ] := Value;
end;

end.

-- And a unit with:

unit Unit2;

interface

uses
  Unit1;

type
  TDerived = class( TBase )
  public
    property Int0: Integer index 0 read GetInt write SetInt;
  end;

implementation

end.


-- now stand in TDerived and do CTRL-SHIFT-C

>> RESULT:

unit Unit2;

interface

uses
  Unit1;

type
  TDerived = class( TBase )
  private
    function GetInt(const Index: Integer): Integer;
    procedure SetInt(const Index, Value: Integer);
  public
    property Int0: Integer index 0 read GetInt write SetInt;
  end;

implementation

{ TDerived }

function TDerived.GetInt(const Index: Integer): Integer;
begin

end;

procedure TDerived.SetInt(const Index, Value: Integer);
begin

end;

end.

The GetInt and SetInt are recreated!
note: When in one unit it seems to work correctly!
Workarounds
None
Attachment
None
Comments

Tomohiro Takahashi at 5/23/2011 6:23:45 PM -
I can not reproduce your issue.

> Now try to expand WantToExpand(). The effect is that GetAnsiStringField and SetAnsiStringField are added to TX again!
Could you provide more detailed [Steps] to verify your issue?
Do you press CTRL+SHIFT+C?
And, what actual result do you get?

Ritsaert Hornstra at 5/26/2011 7:10:21 AM -
I updated the Steps with a full example. Could you please reopen the ticket?

Tomohiro Takahashi at 5/26/2011 7:06:16 PM -
> The GetInt and SetInt are recreated!
It is correct behavior, because GetInt and SetInt methods of parent TBase class are 'private', right?

Ritsaert Hornstra at 5/27/2011 5:10:16 AM -
Hello Mr Takahashi,

My bad; it also does not work correctly with protected,public etc. WHen trying to create a minimal example I should take a few more seconds to see if it is done correctly ;-).

Thus: problem does exist, also when get/set are declared in a reachable section (eg protected etc).

Tomohiro Takahashi at 5/27/2011 5:54:23 AM -
Ok,
Is your issue same as QC#11227 that was reported several years ago?

Ritsaert Hornstra at 5/27/2011 3:20:10 PM -
You could say it is an extension (this ticket talks about properties with indexes the other about non indexed properties). You might consider this a duplicate.

Server Response from: ETNACODE01