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/11/17 13:13:00 UTC

[jira] [Assigned] (GROOVY-10372) STC: check lambda or closure parameter types against target method

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

Eric Milles reassigned GROOVY-10372:
------------------------------------

    Assignee: Eric Milles

> STC: check lambda or closure parameter types against target method
> ------------------------------------------------------------------
>
>                 Key: GROOVY-10372
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10372
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Static Type Checker
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Follow up from GROOVY-10277.  Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test() {
>   Comparator<Integer> cmp = (int one, int two) -> Integer.compare(one,two)
> }
> {code}
> Instead of an error for mismatched generics -- which was the previous disposition of the compiler -- there could be an error for each typed parameter that does not match expectations.  {{ecj}} produces the following error for the above's Java equivalent: "Lambda expression's parameter {{one}} is expected to be of type {{Integer}}"
> These checks should extend to lambdas or closures that are cast, coerced or passed as arguments.
> https://github.com/apache/groovy/blob/eb8854afcf02057f70b8a979a873e0a34393b740/src/test/groovy/transform/stc/LambdaTest.groovy#L243



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