You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/10/06 14:09:00 UTC

[jira] [Assigned] (GROOVY-9763) Regression in groovyc 3.0 and 4.0 and Compile static with generic static method in trait

     [ https://issues.apache.org/jira/browse/GROOVY-9763?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles reassigned GROOVY-9763:
-----------------------------------

    Assignee: Eric Milles

> 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: 4.0.0-alpha-1, 3.0.6
>            Reporter: Arthur Sengileyev
>            Assignee: Eric Milles
>            Priority: Major
>
> 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)