Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.9, 2.5.16, 3.0.10
-
None
Description
The code
import groovy.transform.* import java.util.function.Function @CompileStatic class Foo { final <T> T foo(Function<Reader, T> function) { new StringReader("").withCloseable { reader -> function.apply(reader) } } static void main(String... args) { println new Foo().foo { it.text.empty } } }
fails with
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'true' with class 'java.lang.Boolean' to class 'java.io.StringReader' at Foo$_foo_closure1.doCall(Script1.groovy:10) at Foo$_foo_closure1.call(Script1.groovy) at Foo.foo(Script1.groovy:9) at Foo.main(Script1.groovy:15)
while it works fine with @CompileDynamic. As far as I can see this regression was introduced with 3.0.9.
(see Groovy Web Console as long as deployed version is 3.0.10)