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

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-3, 3.0.9, 2.5.16
    • None
    • 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

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment