DongChunHao opened a new issue, #7293:
URL: https://github.com/apache/netbeans/issues/7293
### Apache NetBeans version
Apache NetBeans 21
### What happened
When I select "a" and perform the extract local variable refactoring, the
new method name is "a1" and I click "OK", an nconsistent code behavior :
public class ExtractVariableTest {
public void method() {
int a;
if (true) {
// select "a" to extract variable refactoring
a = 3;
}
}
}
after refactoring result:

The value originally assigned to a was reconstructed and assigned to a new
local variable, resulting in inconsistent behavior before and after refactoring.
Expected result: For this assignment situation, I think a warning should be
given that local variable extraction and reconstruction operations cannot be
performed
### Language / Project Type / NetBeans Component
_No response_
### How to reproduce
Perform the following actions on the following code:
selecet “”
click “Refactor-Introduce-variable”
new name "a1"
click “ok”
public class ExtractVariableTest {
public void method() {
int a;
if (true) {
// select "a" to extract variable refactoring
a = 3;
}
}
}
### 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists