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

STC: closure param type inference for tuple

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.14, 3.0.19
    • None
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        def list_of_tuple2 = ['a','b'].withIndex()
        print list_of_tuple2.collect{ s,i -> s+i }
      }
      test()
      

      STC rejects this script, saying "Incorrect number of parameters. Expected 1 but found 2" or if "s,i" is "String s, int i" a type error.

      However it runs successfully without STC, printing "[a0, b1]"

      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: