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

CompileStatic Will Not Allow Instance Method In Trait To Call Static Method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.8
    • 2.4.2
    • Static compilation
    • None

    Description

      grv $ groovy -version
      Groovy Version: 2.3.8 JVM: 1.7.0_45 Vendor: Oracle Corporation OS: Mac OS X
      grv $ 
      grv $ cat SomeTrait.groovy 
      @groovy.transform.CompileStatic
      trait SomeTrait {
          static someStaticMethod(){}
      
          void someInstanceMethod() {
              someStaticMethod()
          }
      }
      grv $ 
      grv $ groovyc SomeTrait.groovy 
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      SomeTrait.groovy: 6: [Static type checking] - Cannot find matching method SomeTrait#someStaticMethod(). Please check if the declared type is right and if the method exists.
       @ line 6, column 9.
                 someStaticMethod()
                 ^
      
      1 error
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: