Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Class Completion    [ Add a report in this area ]  
Report #:  91771   Status: Open
Class completion on descendant overriden abstract method: Useless Inherited
Project:  Delphi Build #:  14.0.3593.25826
Version:    15.1 Submitted By:   David Tetard
Report Type:  Minor failure / Design problem Date Reported:  2/24/2011 12:37:10 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   282031
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
If you have the following code (Important: the two classes must be in different units):

Unit One;

TMyAncestor = Class(TObject)
Public
     Procedure Foo; Virtual; Abstract;
End;

Unit Two;

Interface

Uses One;

TMyDescendant = Class(TMyAncestor)
Public
     Procedure Foo; Override;
End;


If you do a Ctrl + C on TMyDescendant's Foo, the following is created:

TMyDescendant.Foo;
Begin
    Inherited;

End;


The "Inherited" appears to be completely useless as there is no point calling an abstract method. This works fine when both classes are in the same unit.
Steps to Reproduce:
See description.
Workarounds
None
Attachment
None
Comments

Tomohiro Takahashi at 2/24/2011 7:04:46 PM -
> Build No: 14.0.3593.25826
I can not reproduce your issue with Delphi 2010(Build No: 14.0.3615.26342).
So, have you already applied all of Updates/Hotfixes?

David Tetard at 2/25/2011 10:28:37 PM -
Yes, you are right and I found why:

If TMyAncestor are in the same unit, the Inherited is not added as expected.

If the two objects are in different units, Inherited is added as shown below:

unit Unit4;

interface

Type
    TAncestor = Class(TObject)
    Public
         Procedure Foo; Virtual; Abstract;
    End;

implementation

end.

============================
unit Unit3;

interface

Uses Unit4;

Type
    TMyObject = Class(TAncestor)
    Public
         Procedure Foo; Override;
    End;

implementation

{ TMyObject }

procedure TMyObject.Foo;
begin
  inherited;

end;

end.

Tomohiro Takahashi at 2/26/2011 4:41:43 AM -
Ok, so please correct [Description] field by using Windows Native QC Client to open/track this issue properly? The standalone client comes with Delphi.
Thanks.

Server Response from: ETNACODE01