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

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

Eric Milles created GROOVY-9997:
-----------------------------------

             Summary: 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


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.}}



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