Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9997

STC: cast or coerce to functional interface fails to infer param types of closure/lambda

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0-alpha-3
    • Component/s: None
    • Labels:
      None

      Description

      Variation of GROOVY-9977. Consider the following:

      @groovy.transform.TypeChecked
      def stc() {
        return (Comparator<Integer>) { a, b -> Integer.compare(a, b) }
      }
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              emilles Eric Milles
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: