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 causes compilation errors. #1297

Open
DongChunHao opened this issue Apr 1, 2024 · 1 comment · May be fixed by #1427
Open

Bug: move method causes compilation errors. #1297

DongChunHao opened this issue Apr 1, 2024 · 1 comment · May be fixed by #1427
Assignees
Labels
bug Something isn't working
Milestone

Comments

@DongChunHao
Copy link
Contributor

When moving the dependentMethod method to the TargetClass class, the use of private field value in dependentMethod resulted in compilation errors after move method refactoring.

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

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

}

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

The refactorin results are as follows:

image

@DongChunHao
Copy link
Contributor Author

@ jjohnstn Please check if this is a bug and let me know. Thank you

@jjohnstn jjohnstn self-assigned this May 23, 2024
@jjohnstn jjohnstn added the bug Something isn't working label May 23, 2024
@jjohnstn jjohnstn added this to the 4.33 M1 milestone May 23, 2024
jjohnstn added a commit to jjohnstn/eclipse.jdt.ui-1 that referenced this issue May 27, 2024
- fix MoveInstanceMethodProcessor.createMethodBody() to perform any
  needed adjustments to field modifiers if required by the move
- add new test to MoveInstanceMethodTests
- fixes eclipse-jdt#1297
@jjohnstn jjohnstn linked a pull request May 27, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants