You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Arthur Sengileyev (Jira)" <ji...@apache.org> on 2020/09/29 21:52:00 UTC
[jira] [Created] (GROOVY-9763) Regression in groovyc 3.0 and 4.0
and Compile static with generic static method in trait
Arthur Sengileyev created GROOVY-9763:
-----------------------------------------
Summary: Regression in groovyc 3.0 and 4.0 and Compile static with generic static method in trait
Key: GROOVY-9763
URL: https://issues.apache.org/jira/browse/GROOVY-9763
Project: Groovy
Issue Type: Bug
Components: Compiler, Static compilation, Static Type Checker
Affects Versions: 3.0.6, 4.0.0-alpha-1
Reporter: Arthur Sengileyev
After upgrading to groovy 3.0 this code fails to compile (can't pass type checker).
{code:java}
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()
{code}
Error output:
{code:java}
% 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 {code}
It compiles fine with 2.5.13.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)