Skip to content

Move method refactoring caused syntax errors due to calling private fields #3604

Open
@DongChunHao

Description

@DongChunHao

[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 "dependentMethod()"
  2. click “Refacator-Move method”

class SourceClass {
private int value;
TargetClass c;
public void setValue(int value) {
this.value = value;
}
public void dependentMethod() {
System.out.println("Dependent method: " + value);
}
}
class TargetClass {
public void callDependentMethod() {
SourceClass source = new SourceClass();
source.dependentMethod();
}
}

refactoring result:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions