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

Regression in invoking method references to methods from List class when called on empty lists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0
    • 4.0.7
    • None
    • None

    Description

      While migrating from Groovy 3 to Groovy 4 I have uncovered a regression in how method references to methods on List are invoked when called on empty lists. The following test case passes on Groovy 3:

          def "method references from List class are invoked correctly on empty lists"() {
              given:
              def streamOfEmptyCollections = [[]].stream()
      
              when:
              def flattened = streamOfEmptyCollections.flatMap(List::stream).toList()
      
              then:
              flattened == []
          }
      

      But on Groovy 4 it fails with the following error:

      Condition not satisfied:
      
      flattened == []
      |         |
      |         false
      [interface java.util.List]
      

      I believe that this regression was introduced by this change to groovy.lang.MetaClassImpl.invokeMethodClosure() which was part of the fix for GROOVY-10057.

      Attachments

        Activity

          People

            emilles Eric Milles
            erdi Marcin Erdmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: