Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0
-
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.