Skip to content

Introduce New Method refactoring with yield statement leads to broken code #8278

Open
@JaroslavTulach

Description

@JaroslavTulach

Apache NetBeans version

Apache NetBeans 24

What happened

Select piece of code with yield statement

Image

and choose "Introduce Method" refactoring.

The generated code is broken. The new method

  • has void return type
  • continues to use yield instead of return

Looks like special treatment of yield is needed when introducing methods. CCing @jlahoda, @lahodaj

Language / Project Type / NetBeans Component

No response

How to reproduce

Select piece of code with yield statement

Image

and choose "Introduce Method" refactoring.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Any

JDK

JDK21

Apache NetBeans packaging

Own source build

Anything else

No response

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)hintskind:bugBug report or fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions