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

Bug:Move method refactoring did not check for issues with calling private fields #1298

Closed
DongChunHao opened this issue Apr 2, 2024 · 2 comments
Assignees
Milestone

Comments

@DongChunHao
Copy link
Contributor

Compilation error occurred when moving dependentMethod() to TargetClass class

class SourceClass {
private int value;
TargetClass c;
public void setValue(int value) {
this.value = value;
}

// remove dependentMethod() to TargetClass
public void dependentMethod() {
System.out.println("Dependent method: " + value);
}
}

class TargetClass {
public void callDependentMethod() {
SourceClass source = new SourceClass();
source.dependentMethod();
}
}

Refactoring results:
image

@jjohnstn jjohnstn self-assigned this May 15, 2024
@jjohnstn jjohnstn added the bug Something isn't working label May 15, 2024
@jjohnstn jjohnstn added this to the 4.32 M3 milestone May 15, 2024
@jjohnstn jjohnstn removed the bug Something isn't working label May 15, 2024
@jjohnstn
Copy link
Contributor

@DongChunHao This is not failing. The move member actually issues a warning that "The visibility of field "tests.SourceClass.value" will be changed to package." This change is made when you choose OK and makes the move work. Is it possible this is a failure in jdt.ls or vscode?

@jjohnstn
Copy link
Contributor

Closing as not a bug in JDT.UI.

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

2 participants