[ 
https://issues.apache.org/jira/browse/GROOVY-12721?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun resolved GROOVY-12721.
---------------------------------
    Resolution: Fixed

Fixed in https://github.com/apache/groovy/pull/3255 (master bc25deb53b48 / 
776a3d511059) and cherry-picked to GROOVY_6_0_X (de781acd629c / 37183e18ef5a).

> Awaitable.all, any, first and allSettled should accept a single list of 
> sources
> -------------------------------------------------------------------------------
>
>                 Key: GROOVY-12721
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12721
>             Project: Groovy
>          Issue Type: Improvement
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 6.x, 7.x
>
>
> {{Awaitable.all}}, {{any}}, {{first}} and {{allSettled}} take {{Object... 
> sources}}. A caller holding a list of tasks, the usual shape when the tasks 
> come out of {{collect}}, has to spread it: {{Awaitable.allSettled(*tasks)}}. 
> Passing the list itself compiles and fails at run time with a message about 
> the list's class:
> {code:groovy}
> def tasks = ['a', 'b', 'c'].collect { m -> async { fetch(m) } }
> def results = await Awaitable.allSettled(tasks)
> {code}
> {noformat}
> IllegalArgumentException: No Awaitable adapter found for type: 
> java.util.ArrayList. Register an AwaitableAdapter via ServiceLoader or 
> AwaitableAdapterRegistry.register().
> {noformat}
> JavaScript's {{Promise.all}}, {{allSettled}}, {{any}} and {{race}} take an 
> iterable, so this is the form people, and the models trained on them, write 
> first. A single argument that is a {{Collection}} has no other meaning today, 
> since a collection is never awaitable, so the combinators can take it as the 
> list of sources.
> Proposal: in {{AwaitCombinators}}, when {{sources}} has one element and it is 
> a {{Collection}}, use its elements; the empty and null checks of {{any}} and 
> {{first}} then apply to those elements. {{Awaitable.all(*tasks)}} keeps 
> working. A sentence in the combinator summary of core-async-await.adoc and in 
> the {{@param sources}} Javadoc.
> Found while scoring Groovy 6.0.0 code written by a language model: with the 
> Groovy documentation available to it through a tool, GPT-6 still wrote the 
> list form.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to