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/23 00:42:00 UTC

[jira] [Updated] (GROOVY-9997) STC: cast or coerce to functional interface fails to infer param types of closure/lambda

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

Eric Milles updated GROOVY-9997:
--------------------------------
    Description: 
Variation of GROOVY-9977. Consider the following:
{code:groovy}
@groovy.transform.TypeChecked
def stc() {
  return (Comparator<Integer>) { a, b -> Integer.compare(a, b) }
}
{code}
When casting or coercing a closure/lambda expression the type checker fails to infer the parameter types.

{{[Static type checking] - Cannot find matching method java.lang.Integer#compare(java.lang.Object, java.lang.Object). Please check if the declared type is correct and if the method exists.}}

  was:
Variation of GROOVY-9977. Consider the following:
{code:groovy}
@groovy.transform.TypeChecked
def stc() {
  return (Comparator<Integer>) { a, b -> Integer.compareTo(a, b) }
}
{code}
When casting or coercing a closure/lambda expression the type checker fails to infer the parameter types.

{{[Static type checking] - Cannot find matching method java.lang.Integer#compareTo(java.lang.Object, java.lang.Object). Please check if the declared type is correct and if the method exists.}}


> STC: cast or coerce to functional interface fails to infer param types of closure/lambda
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9997
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9997
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Variation of GROOVY-9977. Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> def stc() {
>   return (Comparator<Integer>) { a, b -> Integer.compare(a, b) }
> }
> {code}
> When casting or coercing a closure/lambda expression the type checker fails to infer the parameter types.
> {{[Static type checking] - Cannot find matching method java.lang.Integer#compare(java.lang.Object, java.lang.Object). Please check if the declared type is correct and if the method exists.}}



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