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

STC: closure parameter type-checking: declared vs inferred

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0-rc-2, 3.0.12
    • 3.0.12, 4.0.4
    • Static Type Checker
    • None

    Description

      Consider the following:

      import java.util.function.Consumer
      
      def <T> T m(Consumer<? super T> c) {
        // ...
      }
      @groovy.transform.TypeChecked
      void test() {
        this.m { Number n ->
          def big = n.toBigInteger()
        }
      }
      

      Recent fixes for closure param STC (GROOVY-8917, GROOVY-10049, GROOVY-10053, etc.) are producing an error for the param "expected Object actual Number" and an error for the call expression "cannot find method Object#toBigInteger()".

      StaticTypeCheckingVisitor#inferClosureParamterTypes does not use closure expressions to determine placeholder types and there are no other type witnesses.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: