Introduce New Method refactoring with yield statement leads to broken code
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 24
### What happened
Select piece of code with `yield` statement

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

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
Contributor guide
Research direction
Reproduce this in Apache NetBeans 24 on JDK 21 by selecting code containing a yield statement and choosing Introduce Method. Inspect the generated method and its return behavior; done means the refactoring no longer produces a void method that still uses yield, and the resulting code is valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100