Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-alpha-1, 3.0.6
-
None
Description
After upgrading to groovy 3.0 this code fails to compile (can't pass type checker).
import groovy.transform.CompileStatic @CompileStatic trait StaticTrait { static <T> T wrapClosure(Closure<T> callable) { callable() } } class ClassWithTrait implements StaticTrait {} @CompileStatic class ClassCaller { void call() { ClassWithTrait.wrapClosure { println("fails to compile") 0 } } } new ClassCaller().call()
Error output:
% groovyc test1.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test1.groovy: 15: [Static type checking] - Cannot find matching method ClassWithTrait#wrapClosure(groovy.lang.Closure <java.lang.Integer>). Please check if the declared type is correct and if the method exists. @ line 15, column 9. ClassWithTrait.wrapClosure { ^ 1 error
It compiles fine with 2.5.13.