Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.13
-
None
Description
This code will compile:
src/main/groovy/demo/Bar.groovy
package demo import java.util.function.Consumer import groovy.transform.CompileStatic @CompileStatic class Bar { static <T> void foo(T a, Consumer<T> c) { } static void main(args) { def c = { foo('') { println 'hello' } } } }
This code will not compile:
src/main/groovy/demo/Bar.groovy
package demo import java.util.function.Consumer import groovy.transform.CompileStatic @CompileStatic class Bar { static <T> void foo(T a, Consumer<T> c) { } static void main(args) { def c = { // this following line is the only difference int x = 0 foo('') { println 'hello' } } } }
/Users/jeffbrown/projects/project/src/main/groovy/demo/Bar.groovy: 14: [Static type checking] - Cannot call <T> demo.Bar#foo(T, java.util.function.Consumer <T>) with arguments [java.lang.String, groovy.lang.Closure <java.lang.Void>] @ line 14, column 13. foo('') { ^ 1 error
I have only tested with Groovy 2.4.13.