vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Renaming methods causes code behavior to change

Open DongChunHao opened this issue 1 year ago • 0 comments

[provide a description of the issue]

Environment

Operating System: Windows11 JDK version: 17 Visual Studio Code version: 1.88 Java extension version: 1.29

Steps To Reproduce
  1. select "k()"
  2. click "Refactor-Rename"
  3. new method name "m()"

In this example, before the rename, the f() method calls the m() method in the parent class, and after the rename, the f() method calls the method in the subclass renamed m(). The rename causes the code behavior to change, so it is a bug.

class A { void m(Object m){ System.out.println("A"); } } class B extends A{ // rename k to m void k(String m){ System.out.println("B"); } void f(){ m("1"); } }

Current Result:

image

Expected Result: A warning is given during the refactoring process that the name may cause the refactoring behavior to change
Additional Informations

DongChunHao avatar Jul 14 '24 06:07 DongChunHao