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

Groovy classes with @CompileStatic cannot use constants declared on an interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.4
    • 2.0.6
    • Static compilation
    • None
    • Using JDK 6, Groovy 2.0.4.

    Description

      Compile the class below and you'll get the following compilation error:

      [Static type checking] - The variable [myStringConstant] is undeclared.

      import groovy.transform.CompileStatic

      interface MyInterface {
      String myStringConstant = 'STRING'

      String myMethod()
      }

      @CompileStatic
      class MyClass implements MyInterface {
      @Override String myMethod()

      { myStringConstant }

      }

      Attachments

        1. MyClass.groovy
          0.2 kB
          Brett Borchardt

        Activity

          People

            melix Cédric Champeau
            bborchardt Brett Borchardt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: