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 2021/03/09 20:22:00 UTC

[jira] [Commented] (GROOVY-9974) @CompileStatic with Method References

    [ https://issues.apache.org/jira/browse/GROOVY-9974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17298322#comment-17298322 ] 

Eric Milles commented on GROOVY-9974:
-------------------------------------

Generics checking matches {{Closure<Boolean>}} to {{Predicate<? super String>}} and connects {{Boolean}} to {{String}}, which is incorrect.  The predicate type parameter refers to the input and the closure type parameter refers to the output, so there is no correlation to make.

> @CompileStatic with Method References
> -------------------------------------
>
>                 Key: GROOVY-9974
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9974
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 3.0.6, 3.0.7
>         Environment: JDK 11
>            Reporter: Michael Spahn
>            Assignee: Eric Milles
>            Priority: Major
>
> The following code worked fine until 3.0.5:
> {code:java}
> @Test
> @CompileStatic
> void methodReference() {
>     def list = ['']
>     list.removeIf(String::isBlank)
>     assert list.empty
> }
> {code}
> Using version 3.0.6/3.0.7 this no longer compiles:
> {noformat}
> Groovyc: [Static type checking] - Cannot call java.util.List <java.lang.String>#removeIf(java.util.function.Predicate <? super java.lang.String>) with arguments [groovy.lang.Closure <java.lang.Boolean>]
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)