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

Problem With @CompileStatic And Static Trait Members

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.0-rc-2
    • 2.4.1
    • None
    • None

    Description

      SomeTrait.groovy
      @groovy.transform.CompileStatic
      trait SomeTrait {
          static List stuff
      
          static void initStuff(List l) {
              stuff = l
          }
      }
      
      $ groovy -version
      Groovy Version: 2.4.0-rc-2 JVM: 1.7.0_45 Vendor: Oracle Corporation OS: Mac OS X
      $ 
      grv $ groovyc SomeTrait.groovy 
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      SomeTrait.groovy: 6: [Static type checking] - Cannot find matching method SomeTrait#SomeTrait__stuff$set(java.util.List). Please check if the declared type is right and if the method exists.
       @ line 6, column 9.
                 stuff = l
                 ^
      
      1 error
      
      $
      

      If I remove the @CompileStatic the code runs and does what I expect it to do.

      Attachments

        Issue Links

          Activity

            People

              melix Cédric Champeau
              brownj Jeff Brown
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: