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

   ### Description
   
   Refactoring should be supported for records, too.
   
   ```
   public class RecordTest {
       public static final record TestRecord(int id, String name) {
       }
   
       public static void main(final String[] args) {
           new TestRecord(1, "foo");
       }
   }
   ```
   When selecting _Refactor → Change method parameters_ in the context menu in 
the line containing `record`, the message “Cannot refactor this object.” 
appears.
   
   Using the same menu entry in the line containing `new`, the _Change Method 
Parameters_ window appears, but when using it do change the order of the 
parameters, NetBeans (17) generates a new constructor inside the `record` which 
will not compile. The result is
   ```
   public class RecordTest {
       public static final record TestRecord(int id, String name) {
           public TestRecord(String name, int id) {
           }
       }
   
       public static void main(final String[] args) {
           new TestRecord("foo", 1);
       }
   }
   ```
   and the compiler message is “error: constructor is not canonical, so its 
first statement must invoke another constructor of class TestRecord”. Removing 
parameters via the _Change Method Parameters_ window also generates a new 
invalid constructor.
   
   ### Use case/motivation
   
   _No response_
   
   ### Related issues
   
   _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