Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4829

Incorrect hint about unused assigned value in switch statement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 12.1
    • None
    • java - Hints
    • None
    • Java 15, Windows 10

    Description

      In some switch statements NetBeans displays a hint saying the assigned value is never used even though it is:

      public final class SwitchAssignedValueNeverUsed {
      
          public enum E {
              A,
              B;
          }
      
          public static void main(final String[] args) {
              E e = E.A;
              String s;
              switch (e) {
                  case A -> s = "a"; // Hint: The assigned value is never used
                  case B -> s = "b";
                  default ->
                      throw new AssertionError(e.name());
              }
              System.out.println(s);
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            striderapache dennis lucero
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: