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

STC: closure parameter type-checking: declared vs inferred

    XMLWordPrintableJSON

Details

    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: