Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Refactoring/Rename    [ Add a report in this area ]  
Report #:  34297   Status: Closed
Rename refactoring doesn't work with overloaded methods.
Project:  Delphi Build #:  10.0.2288.42451
Version:    10.0 Submitted By:   Dimitry Timokhov
Report Type:  Minor failure / Design problem Date Reported:  9/21/2006 9:33:33 PM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   242045
Resolution: Fixed (Resolution Comments) Resolved in Build: : 11.0.2573.3635
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
See "Steps" tabsheet.
Steps to Reproduce:
1. Type this project

{$o-}
program Project1;
type
   TMyClass = class
      public function M(A: Integer): Integer; overload;
      public function M(A: String): String; overload;
   end;
function TMyClass.M(A: Integer): Integer;
begin
   Result := A;
end;
function TMyClass.M(A: String): String;
begin
   Result := A;
end;
var
   C: TMyClass;
   I: Integer;
   S: String;
begin
   C := TMyClass.Create();
   I := C.M(1);
   S := C.M('1');
end.

2. Try to complie. All OK - the code is correct.

3. Place cursor just before the first appearance of M like this (i marked cursor position with help of symbol "|")

  TMyClass = class
      public function |M(A: Integer): Integer; overload;
      public function M(A: String): String; overload;
   end;

4. Apply Rename refactoring. Rename M to M1

5. EXPECTED behaviour. Project changes to

{$o-}
program Project1;
type
   TMyClass = class
      public function M1(A: Integer): Integer; overload;
      public function M(A: String): String; overload;
   end;
function TMyClass.M1(A: Integer): Integer;
begin
   Result := A;
end;
function TMyClass.M(A: String): String;
begin
   Result := A;
end;
var
   C: TMyClass;
   I: Integer;
   S: String;
begin
   C := TMyClass.Create();
   I := C.M1(1);
   S := C.M('1');
end.

ACTUAL behaviour. Project changes to

{$o-}
program Project1;
type
   TMyClass = class
      public function M1(A: Integer): Integer; overload;
      public function M(A: String): String; overload;
   end;
function TMyClass.M1(A: Integer): Integer;
begin
   Result := A;
end;
function TMyClass.M(A: String): String;
begin
   Result := A;
end;
var
   C: TMyClass;
   I: Integer;
   S: String;
begin
   C := TMyClass.Create();
   I := C.M1(1);
   S := C.M1('1'); !!!!!! ERROR HERE
end.

=====================
If you apply refactoring to M(A: String): String you a also get unexpected results.


Workarounds
None
Attachment
None
Comments

Leo Siefert at 9/22/2006 4:47:11 AM -
That's ugly!

Server Response from: ETNACODE01