[ https://issues.apache.org/jira/browse/GROOVY-11486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17939394#comment-17939394 ]
ASF GitHub Bot commented on GROOVY-11486: ----------------------------------------- daniellansun commented on PR #2157: URL: https://github.com/apache/groovy/pull/2157#issuecomment-2763249502 Merged. Thanks > DGM flatten return type is often incorrect > ------------------------------------------ > > Key: GROOVY-11486 > URL: https://issues.apache.org/jira/browse/GROOVY-11486 > Project: Groovy > Issue Type: Bug > Reporter: Eric Milles > Assignee: Eric Milles > Priority: Major > > The groovy method {{flatten}} for {{Object[]}}, {{Collection}}, {{Iterable}}, > {{List}}, {{Set}} and {{SortedSet}} does not inference to the correct return > type except for the case where there were no aggregate elements to flatten. > There isn't anything the type checker can do to detect the return type for > non-trivial cases, but the {{flatten}} methods that accept a transform are a > reasonable model: > {code:java} > public static <T, E> Collection<T> flatten(Iterable<E> self, Closure<?> > flattenUsing) { > // ... > } > {code} > This allows the programmer to declare the expected type: > {code:groovy} > def list = [1,[2],[[3],[4]]] > Collection<Integer> coll = list.flatten(Closure.IDENTITY) > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)