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/12/30 19:33:00 UTC

[jira] [Commented] (GROOVY-10436) STC: closure parameter type-checking: declared vs inferred

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

Eric Milles commented on GROOVY-10436:
--------------------------------------

It is possible to replace "this.m \{ Number n ->" with "this.<Number>m \{ n ->" in case anyone runs into this.

> STC: closure parameter type-checking: declared vs inferred
> ----------------------------------------------------------
>
>                 Key: GROOVY-10436
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10436
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 4.0.0-rc-2
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> import java.util.function.Consumer
> def <T> T m(Consumer<? super T> c) {
>   // ...
> }
> @groovy.transform.TypeChecked
> void test() {
>   this.m { Number n ->
>     def big = n.toBigInteger()
>   }
> }
> {code}
> Recent fixes for closure param STC (GROOVY-8917, GROOVY-10049, GROOVY-10053, etc.) are producing an error for the param "expected Object actual Number" and an error for the call expression "cannot find method Object#toBigInteger()".
> {{StaticTypeCheckingVisitor#inferClosureParamterTypes}} does not use closure expressions to determine placeholder types and there are no other type witnesses.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)