Skip to content

Inline method refactoring causes naming conflict. #7298

@DongChunHao

Description

@DongChunHao

Apache NetBeans version

Apache NetBeans 21

What happened

When I select " inlineMethod() " and perform the inline method refactoring, and i click "OK", a syntax error occurs:

public class InlineMethodTest{
public void main() {
class T {
public T() {}
}
inlineMethod();
}
// inline method
public void inlineMethod() {
class T {
T t;
public T() {}
}
}
}

Refactoring result :
image

Inner class name conflict;

Expected result: Before inline methods, it is necessary to check for naming conflicts. If so, the identifier name should be modified or syntax errors should be reported

Language / Project Type / NetBeans Component

No response

How to reproduce

Perform the following actions on the following code:

selecet “inlineMethod() ”
click “Refactor-inline”
click “ok”

public class InlineMethodTest{
public void main() {
class T {
public T() {}
}
inlineMethod();
}
// inline method
public void inlineMethod() {
class T {
T t;
public T() {}
}
}
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugBug report or fixneeds:triageRequires attention from one of the committers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions