You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/06/21 10:00:27 UTC

[GitHub] [netbeans] sviperll opened a new issue, #4257: Record compact constructor parameters are considered unused

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

   ### Apache NetBeans version
   
   Apache NetBeans 14
   
   ### What happened
   
   Defining compact constructor almost always results in "unused local variable" warning, because NetBeans is unaware of implicit field assignments that happen after compact constructor code is executed.
   
   In an example:
   
   ````java
   record MyRecord(List<String> list, int[] ints) {
       MyRecord {
           list = List.copyOf(list); // WARNING: unused local variable
           ints = Arrays.copyOf(ints); // WARNING: unused local variable
       }
   }
   ````
   
   I expect there to be no warnings, because above code is totally legitimate and even more recommended way to use compact constructor.
   
   ### How to reproduce
   
   Define any record with compact constructor that assigns to constructor parameters.
   
   ### Did this work correctly in an earlier version?
   
   No
   
   ### Operating System
   
   Fedora 34
   
   ### JDK
   
   JDK 18
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No
   
   ### Code of Conduct
   
   Yes


-- 
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: notifications-unsubscribe@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [I] Record compact constructor parameters are considered unused [netbeans]

Posted by "dstutz (via GitHub)" <gi...@apache.org>.
dstutz commented on issue #4257:
URL: https://github.com/apache/netbeans/issues/4257#issuecomment-1764595042

   I'm seeing this still happening on NB 19.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [I] Record compact constructor parameters are considered unused [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien closed issue #4257: Record compact constructor parameters are considered unused
URL: https://github.com/apache/netbeans/issues/4257


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [I] Record compact constructor parameters are considered unused [netbeans]

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on issue #4257:
URL: https://github.com/apache/netbeans/issues/4257#issuecomment-2037728648

   @Eccenux is this reproducible in NB21?
   
   @mbien is this meant to still be open?


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on issue #4257: Record compact constructor parameters are considered unused

Posted by GitBox <gi...@apache.org>.
mbien commented on issue #4257:
URL: https://github.com/apache/netbeans/issues/4257#issuecomment-1186237566

   `ctrl+r` rename refactoring is also not renaming the record field, this might help finding the issue. Seems like the IDE thinks those are two separate fields.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [I] Record compact constructor parameters are considered unused [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on issue #4257:
URL: https://github.com/apache/netbeans/issues/4257#issuecomment-2079146841

   @neilcsmith-net wait, I was wrong. This was indeed fixed in NB 20, sorry!
   
   (although NB still thinks components and constructor parameters are two different things - renaming/highlighting does not work properly)


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [I] Record compact constructor parameters are considered unused [netbeans]

Posted by "Eccenux (via GitHub)" <gi...@apache.org>.
Eccenux commented on issue #4257:
URL: https://github.com/apache/netbeans/issues/4257#issuecomment-2037713920

   Another example for minimal value validation (NB version 19):
   ```java
   	public record WaitOptions(int timeoutSeconds, boolean expectSuccess) {
   		public WaitOptions {
   			if (timeoutSeconds <= 0) {
   				timeoutSeconds = 5; // NBv19 Warning: Unused Assignment
   			}
   		}
   	}
   ```
   The assignment is used though, because:
   `var opt = new WaitOptions(0, true)` results in `opt.timeoutSeconds  == 5`.
   


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [I] Record compact constructor parameters are considered unused [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on issue #4257:
URL: https://github.com/apache/netbeans/issues/4257#issuecomment-2037746159

   @neilcsmith-net yes, NB thinks record components and the constructor parameters are two different fields, this is the cause for several issues, also during refactoring. You can also see this while highlighting is active (cursor over identifier).


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists