Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187430

Parser fails to handle constant patterns involving enums

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Withdrawn
    • Icon: P4 P4
    • repo-amber
    • None
    • tools
    • generic
    • generic

      This program fails to compile:

      import java.util.ArrayList;

      enum Day {
          Sunday,
          Monday,
          Tuesday
      };

      public class X {
          public static void main(String [] args) {
              Day day = null;
              
              switch (day) {
                  case Sunday: break;
                  case Monday: break;
              }

              if (day __matches Sunday) {
                  System.out.println("Blah");
              }
          }
      }

      X.java:18: error: cannot find symbol
              if (day __matches Sunday) {
                                ^
        symbol: variable Sunday
        location: class X
      1 error

            gbierman Gavin Bierman
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: