You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:32:00 UTC

[jira] [Closed] (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 ]

Paul King closed GROOVY-10372.
------------------------------

> 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
>             Fix For: 4.0.0-rc-1
>
>
> 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)