apache / netbeans

Apache NetBeans

Home Page:https://netbeans.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move method refactoring caused syntax errors due to method being moved to enumeration

DongChunHao opened this issue · comments

Apache NetBeans version

Apache NetBeans 21

What happened

When I select "moveMethod()" and perform the move method refactoring, and i click "OK", a syntax error:
class SourceClass{
private TargetClass target;
public SourceClass(TargetClass target) {
this.target = target;
}
// move method
public void moveMethod(TargetClass parameter) {
((TargetClass) target.abstractField).methodWithSameName();
}
}
interface TargetClass {
Object abstractField = null;
void methodWithSameName();
}

refactoring result:
image

Expected result: Check for grammar errors before and after refactoring, and if so, provide error prompts

Language / Project Type / NetBeans Component

No response

How to reproduce

When I select "moveMethod()" and perform the move method refactoring, and i click "OK", a syntax error:
class SourceClass{
private TargetClass target;
public SourceClass(TargetClass target) {
this.target = target;
}
// move method
public void moveMethod(TargetClass parameter) {
((TargetClass) target.abstractField).methodWithSameName();
}
}
interface TargetClass {
Object abstractField = null;
void methodWithSameName();
}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows11

JDK

20

Apache NetBeans packaging

Apache NetBeans platform

Anything else

No response

Are you willing to submit a pull request?

No