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

STC: support coerced closure argument destructuring (for list and tuple)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-1
    • Static Type Checker
    • None

    Description

      Consider the following:

      import java.util.function.Consumer
      import static groovy.lang.Tuple.tuple
      @groovy.transform.TypeChecked test() {
        Consumer<Tuple3<String,Number,?>> c = { x, y, z -> print y }
        c.accept(tuple("",(Number)42,null))
      }
      test()
      

      STC error: "Wrong number of parameters for method target accept(groovy.lang.Tuple3<java.lang.String, java.lang.Number, ?>)"

      This kind of list/tuple destructuring is supported by the dynamic runtime (see ClosureMetaClass).

      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: