Skip to content

GROOVY-7001: DGM: return exact type for methods accepting collector#1656

Merged
paulk-asert merged 1 commit intomasterfrom
GROOVY-7001
Nov 26, 2021
Merged

GROOVY-7001: DGM: return exact type for methods accepting collector#1656
paulk-asert merged 1 commit intomasterfrom
GROOVY-7001

Conversation

@eric-milles
Copy link
Member

https://issues.apache.org/jira/browse/GROOVY-7001

I stopped short of collectEntries methods. They don't have quite the same problem -- map return is probably okay, whereas the distinction between set, list and collection is often important.

I also changed the return type of some variants to List and added the Collection bridges.

There is some inconsistency between some the variations. In cases where the input and output types are different, collect (except map variant) is listing the input type first where collectMany and others list input type(s) second. I did not make any changes (except to use E instead of S).

    <E, T> List<T> collect(E[] self, @ClosureParams(FirstParam.Component.class) Closure<T> transform)
    <T, K, V> List<T> collect(Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure<T> transform)
    <T, E> List<T> collectMany(E[] self, @ClosureParams(FirstParam.Component.class) Closure<...> projection)
    <T, K, V> List<T> collectMany(Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure<...> projection)

@paulk-asert paulk-asert merged commit 99199e4 into master Nov 26, 2021
Copy link
Contributor

@paulk-asert paulk-asert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes seem okay to me and japicmp seems happy.

@paulk-asert paulk-asert deleted the GROOVY-7001 branch November 26, 2021 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants