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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.6
    • 2.3.8
    • Compiler
    • None
    • groovy 2.3.6

    Description

      Code like following:

      interface B {
      	public static final CONST = "a"
      }
      
      class C implements B {
      }
      
      @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 C.CONST
      			}
      		}
      	}
      }
      
      println A.doSomething()
      

      fails with this compilation error:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 16: Access to C#CONST is forbidden @ line 16, column 12.
                                      return C.CONST
                    ^
      
      1 error
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            druid0523 LibX
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: