Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-11198

access to public static variable forbidden in enum

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 5.0.0-alpha-1, 5.0.0-alpha-2
    • 5.0.0-alpha-3
    • Static compilation
    • None

    Description

      With static compilation, accessing a public static class variable within an enum causes a compilation error.

      import groovy.transform.CompileStatic
      
      @CompileStatic  // compiles without this
      class PublicStaticInEnum {
          public static double FOO = 0.0d  // compiles without "public"
      
          enum MyEnum {
             FOO_VAL(FOO)  // Access to example.PublicStaticInEnum$MyEnum#FOO is forbidden
      
             double myDouble
      
             MyEnum(double myDouble) {
                this.myDouble = myDouble
             }
          }
      } 

      This example fails to compile with:  Access to example.PublicStaticInEnum$MyEnum#FOO is forbidden

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              jasongarrett Jason Garrett
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: