usersuis opened a new issue, #7428:
URL: https://github.com/apache/netbeans/issues/7428

   ### Apache NetBeans version
   
   Apache NetBeans 21
   
   ### What happened
   
   Using "introduce method" on "instanceof" caused compile error in output 
program.
   
   ### Language / Project Type / NetBeans Component
   
   Java Maven Project Java Application
   
   ### How to reproduce
   
   
   Input program:
   ```
   class X {
           private void foo(Object o) {
               if (o instanceof X x) { // select the entire o instanceof X x
                   System.out.println(x.toString());
                   x.foo(null);
               }
   
           }
       }
   ```
   
   Steps:
   Select “o instanceof X x”
   Refactor -> Introduce -> Method
   
   
   Actual output:
   ```
   class X {
           private void foo(Object o) {
                   if (extract1(o)) { // select the entire o instanceof X x
                           System.out.println(x.toString());
                           x.foo(null);
                   }
   
           }
   
           private boolean extract1(Object o) {
               return o instanceof X x;
           }
       }
   ```
   
   Expected result:
   Prevent from introducing method on "instanceof"
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows 11
   
   ### JDK
   
   22.0.1
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### 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

Reply via email to