Groovy 使用@CompileStatic时从另一个调用闭包

Groovy 使用@CompileStatic时从另一个调用闭包,groovy,closures,compile-static,Groovy,Closures,Compile Static,当从@CompileStatic下的另一个闭包隐式调用闭包时,调用方不知何故进入了递归循环。您能否发现代码中的问题,或者这是Groovy的问题: import groovy.transform.CompileStatic @CompileStatic class Main { static main(args) { TestClass testclass = new TestClass() testclass.foo() //testcl

当从@CompileStatic下的另一个闭包隐式调用闭包时,调用方不知何故进入了递归循环。您能否发现代码中的问题,或者这是Groovy的问题:

import groovy.transform.CompileStatic

@CompileStatic
class Main {
    static main(args) {
        TestClass testclass = new TestClass()
        testclass.foo()
        //testclass.bar() // compile error for closure with @CompileStatic 
        testclass.bar.call()  // compiles and works fine
    }
}

@CompileStatic
class TestClass {
    void foo () {
        println('In foo')
        bar() // inside a method -- works fine
    }

    Closure bar = {
        println('In bar')
        //baz() // What's going on here?? It compiles, but instead
        //         of calling baz, this recurses on itself (seemingly)
        baz.call() // this works fine
    }

    Closure baz = {
        println('In baz')
    }
}
[Groovy版本:2.4.5]

注意:这里讨论了一个类似的问题,但是Groovy的相关问题表示它已经被修复了