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

STC: closure parameter metadata after re-assignment of variable

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        def c = { p = 'foo' -> return p }
        assert c('bar') == 'bar'
        assert c() == 'foo'
      
        c = { p, q = 'baz' -> '' + p + q }
        assert c('foo', 'bar') == 'foobar'
        assert c('foo') == 'foobaz'
      
        c = { p, q = p.toString() -> '' + p + q }
        assert c('foo', 'bar') == 'foobar'
        assert c('foo') == 'foofoo'
      }
      test()
      

      When "c" is assigned a new closure, the parameter metadata is not updated on the original variable. This results in errors for "c('foo','bar')" calls, which are not compatible with the original closure signature.

      GROOVY-10072, GROOVY-11394

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: