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

@CompileStatic: can't access static field from nested closures

    XMLWordPrintableJSON

Details

    Description

      The following code:

      @groovy.transform.CompileStatic
      class A {
      
        public static final CONST = "a"
      
        public static List doSomething() {
          return (0..1).collect{ int x ->
            (0..1).collect{ int y ->
              return CONST
            }
          }
        }
      }
      A.doSomething()
      

      fails with this compilation error:

      Access to java.lang.Object#CONST is forbidden at line: -1, column: -1
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            eman Emanuel Alasu
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: