pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 356 forks source link

[RB] RBReplaceMessageSendTransformation is wrong #14775

Open Ducasse opened 1 year ago

Ducasse commented 1 year ago

Right now if you want to replace #old by #new, the method new should be defined in the class of the method containing #old. However the refactoring will happily perform the following change

callerOfOld

     ^ a old

into

callerOfOld

     ^ a new

So there is a misconception between the existence of the method and the fact that the transformation is applied.

The check that a method should be defined in the class is good for rename (rename is using RBReplaceMessageSendTransformation) because during renaming a new method with the new name is defined in the class.

May be one solution is to rename RBReplaceMessageSendTransformation into RBReplaceSelfMessageSendTransformation and make sure that the matcher only matches self.

hernanmd commented 7 months ago

If I understood the issue correctly, I couldn't reproduce it (maybe it is already solved?) Please see the video:

https://github.com/pharo-project/pharo/assets/4825959/c9c4fa0f-179b-4ad9-85d8-948915326050