Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Move method refactoring” causes the method call relationship to change #1865

Open
assdfsdafasfa opened this issue Dec 19, 2024 · 0 comments

Comments

@assdfsdafasfa
Copy link

Select the m() method in class C, select the move method refactoring, move it to class B, before refactoring, the f() method calls the m() method of class A, after refactoring, the f() method calls the m() method of class B。

Code before refactoring:

class A {
    void m(Object m) {
        System.out.println("A");
    }
}

class B extends A {
    void k(String m) {
        System.out.println("B");
    }

    void f() {
        m("1");
    }
}

class C {
    B b;
    // move m() to class B
    void m(String m) {
        System.out.println("B");
    }
}

Code after refactoring:

class A {
    void m(Object m) {
        System.out.println("A");
    }
}

class B extends A {
    void k(String m) {
        System.out.println("B");
    }

    void f() {
        m("1");
    }

    // move m() to class B
    void m(String m) {
        System.out.println("B");
    }
}

class C {
    B b;
}

Expected result (correct result):Give an error prompt before executing the refactoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant