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

Static compilation issue between static and non static methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.8, 4.0.0-alpha-3
    • None
    • Static compilation
    • None

    Description

      The following code fails with the exception 

       

      ideaGroovyConsole.groovy: 19: [Static type checking] - Non static method Bar#run cannot be called from static context
       @ line 19, column 17.
       println Bar.run(Foo)

       

       

      import groovy.transform.CompileStatic
      class Bar {
          static String run(Class cls, String... args) { return "ok" }
          void run(Class type) {}
      }
      @CompileStatic
      class Foo {
          static void go() { println Bar.run(Foo) }
      }
      Foo.go()
      

       This worked in Groovy 3.0.7

       

      Attachments

        1. screenshot-1.png
          31 kB
          Eric Milles

        Activity

          People

            emilles Eric Milles
            Schlogen James Kleeh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: