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

Adding extension method 'call' on ArrayList with Closure as a parameter stopped working in 3.0.x

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0-beta-1, 3.0.0-rc-1, 3.0.5
    • 4.0.0-alpha-1, 3.0.6
    • parser
    • None
    • Important

    Description

      Custom extension like this

      class CustomExtension {
          static MyData call(ArrayList header, Closure code) {
              new MyData(data: header.join(":") + " " + code())
          }
      
          static MyData test(ArrayList header, Closure code) {
              new MyData(data: header.join(":") + " " + code())
          }
      }
      
      

      used to work with Groovy 2.5.12

      class CustomExtensionTest {
          @Test
          void "implicit call on array with closure used to work"() {
              def result = [1, 2, 3] {
                  "world"
              }
      
              assert result.data == '1:2:3 world'
          }
      
          @Test
          void "explicit call on array with closure still works"() {
              def result = [1, 2, 3].test {
                  "world"
              }
      
              assert result.data == '1:2:3 world'
          }
      }
      

      with Groovy 3.0.x I get this error instead 

      groovy.lang.MissingMethodException: No signature of method: regression.CustomExtensionTest.[1, 2, 3]() is applicable for argument types: (regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1) values: [regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1@8b87145]
      

      Is this intentional?

      I have attached a maven project to reproduce.

       

      Attachments

        1. image-2020-08-19-07-40-33-584.png
          36 kB
          Paul King
        2. image-2020-08-19-07-38-38-768.png
          35 kB
          Paul King
        3. groovy3-call-regression.zip
          9 kB
          Mykola Golubyev

        Activity

          People

            emilles Eric Milles
            ninside Mykola Golubyev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 50m
                50m