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/10/01 06:41:17 UTC

[GitHub] [netbeans] negora opened a new issue, #4709: Warning about unused variable disappears when adding private nested record

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

   ### Apache NetBeans version
   
   Apache NetBeans 15
   
   ### What happened
   
   I've a method whose body contains an unused variable. NetBeans reports about this issue right. However, if I add a `private` nested `record` to my class, then the warning disappears. By *disappears* I mean that is not detected as a proper warning anymore:
   
   * The light bulb isn't shown in the left margin of the editor.
   
   * The yellow line isn't shown in the right margin of the editor.
   
   * If I run *Source* → *Inspect...* and choose the hint *Probable bugs* → *Unused element*, it's not detected anymore.
   
   It's strange, because the unused variable is still underlined, but in gray color, not in yellow. And if you hover it with the mouse pointer, the IDE still shows the tip *Variable X is not used*.
   
   Other odd fact: If you change the visibility of the `record` to `public`, `protected` or *package-private*, then the warning comes back.
   
   
   ### How to reproduce
   
   Use this so simple code to reproduce the problem:
   
   ```java
   public class MyClass {
   
   	public void myMethod () {
   		int x = 1;  // << Unused variable.
   	}
   
   	private record MyRecord (String myField) {
   	}
   
   }
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Debian GNU/Linux 11.5 (Bullseye)
   
   ### JDK
   
   OpenJDK Runtime Environment (build 17.0.4+8-Debian-1deb11u1)
   
   ### 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


[GitHub] [netbeans] negora commented on issue #4709: Warning about unused variable disappears when adding private nested record

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

   I've found another case, similar to the previous one, in which the visibility of a class member affects the result of this type of check. However, this time it affects a method parameter instead of a local variable. Look at this:
   
   ```java
   public class Main {
   
       public Main() {
           checkParameter(1);
       }
   
       public static void checkParameter(int myParameter) {
                                       // ^^^ This variable should be marked as unused,
                                       // but it isn't.
       }
   
   }
   ```
   
   Now, if you change the visibility of the method from `public` to `private`, NetBeans correctly detects that `myParameter` is not used at all in the body of the method.
   
   I've tested this in versions 13, 14 and 15 and this *bug* happens in all them.
   
   I was tempted to open a separate issue, because I'm not sure that it's 100% related to the original issue. If you think that it deserves a separate one, please, let me know.
   


-- 
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] negora commented on issue #4709: Warning about unused variable disappears when adding private nested record

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

   @mbien I just tried in NetBeans IDE 13, and it works OK. So whatever that causes this error appeared between versions 13 and 14. Thank you.
   


-- 
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 #4709: Warning about unused variable disappears when adding private nested record

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

   I just checked and it is also reproducible in NB 14. So its not a recent regression.


-- 
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] Warning about unused variable disappears when adding private nested record [netbeans]

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

   Just a little update about the first case that I presented in this report. If I remove all the fields of the `record` and leave it empty, the warning the appears again. Example:
   
   ```java
   public class MyClass {
   
       public void myMethod () {
           int x = 1;
           // ^^^ Unused variable.
       }
   
       private record MyRecord () {
                            // ^^^ Empty record.
       }
   
   }
   ```
   


-- 
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