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

Access to package-scoped static field is forbidden for inner class in static compilation mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.0-alpha-4, 2.5.6
    • 3.0.0-beta-1, 2.5.7
    • None
    • None

    Description

      Given:

       

      import groovy.transform.CompileStatic
      import groovy.transform.PackageScope
      @CompileStatic
      class Test {
        @PackageScope
        static final String S = 'Some constant'
        static class Inner {
          String method() {
            S
          }
        }
      }
      

      there is a compilation error:

       

       

      Access to Test#S is forbidden @ line -1, column -1.

      No error without @CompileStatic.

       

      Analogous code works in Java

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              grv87 Basil Peace
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h