[ 
https://issues.apache.org/jira/browse/GROOVY-12839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152307#comment-18152307
 ] 

ASF GitHub Bot commented on GROOVY-12839:
-----------------------------------------

testlens-app[bot] commented on PR #3367:
URL: https://github.com/apache/groovy/pull/3367#issuecomment-7233902315

   ## 🚨 TestLens detected 2 failed tests 🚨
   
   ### Test Summary
   > [!TIP]
   > Inspect all details with the [TestLens 
CLI](https://testlens.app/docs/features/cli): `testlens pr 3367`
   
   #### [Build and test / lts \(25, 
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/46105036891/job/140855770831?pr=3367)
 > :test
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | GrabResolverTest > testResolverDefinitionResolvesDependency\(\) | ❌ | 
0% 🟢 |
   | GrabResolverTest > 
testResolverDefinitionResolvesDependencyWithShorthand\(\) | ❌ | 0% 🟢 |
   
   🏷️ Commit: 4268ed9dd43a95dfb5d1c00e55e67a9fb8a95b53
   ▶️ Tests:  79628 executed
   🟡 Checks: 10/25 completed
   
   ### Test Failures
   
   <details><summary><strong>GrabResolverTest > 
testResolverDefinitionResolvesDependency()</strong> (:test in <a 
href="https://github.com/apache/groovy/actions/runs/46105036891/job/140855770831?pr=3367";>Build
 and test / lts (25, ubuntu-latest)</a>)</summary>
   
   ```
   java.lang.AssertionError: Forked JVM for 
groovy.grape.GrabResolverTest#testResolverDefinitionResolvesDependency failed:
   org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
failed:
   General error during conversion: Error grabbing Grapes 

> Packed closure with one typed parameter rejects a single List argument that a 
> closure class destructures
> --------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12839
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12839
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 6.0.0, 6.0.1
>            Reporter: Scott Murphy Heiberg
>            Priority: Blocker
>
> GEP-27 closure packing (@PackedClosures, -Dgroovy.target.closure.pack=true; 
> incubating) is meant to be indistinguishable from the closure class the same 
> literal compiles to. The class comment of 
> org.codehaus.groovy.runtime.PackedClosure says:
> {quote}
> Argument adaptation on every route replicates metaclass dispatch on a 
> generated closure class: arity mismatches raise MissingMethodException, a 
> single List destructures across a non-one-parameter signature, trailing-array 
> parameters vararg-collect, and per-parameter coercion follows the metaclass 
> compatibility rules
> {quote}
> A generated closure class does not limit the destructuring to "a 
> non-one-parameter signature". ClosureMetaClass#invokeMethod selects doCall 
> for the arguments as given, and when no doCall applies and the call has 
> exactly one argument that is a List, selects again for the elements of the 
> list and invokes that method with them. So a closure with one typed parameter 
> that is not a supertype of the list takes a one-element list as it takes the 
> element. The packed form keeps the list as the argument and fails.
> This is how Spock invokes a mock response closure (the arguments of the 
> invocation as one List), so a packed response closure with one typed 
> parameter fails. It was found that way.
> {code:groovy}
> class ListArg {
>     static void main(String[] args) {
>         Closure<Integer> c = { String s -> s.length() }
>         println c.call(['four'])
>     }
> }
> {code}
> Expected (and what {{java -cp groovy-6.0.1.jar groovy.ui.GroovyMain 
> ListArg.groovy}} prints):
> {noformat}
> 4
> {noformat}
> Actual with {{-Dgroovy.target.closure.pack=true}}, or with 
> @groovy.transform.PackedClosures on the class, dynamic or @CompileStatic:
> {noformat}
> groovy.lang.MissingMethodException: No signature of method: doCall for class: 
> org.codehaus.groovy.runtime.PackedClosure$Fixed1 is applicable for argument 
> types: (ArrayList) values: [[four]]
> {noformat}
> The same on every route: Closure#call(Object), Closure#call(Object...), 
> c(['four']), c.call(['four']) and c.doCall(['four']) from dynamic code. 
> Reproduced with 6.0.0, 6.0.1 and master (7.0.0-SNAPSHOT).
> Comparing each literal compiled both ways, with a single List or a single 
> null as the argument, shows the other places where the two differ for the 
> same reason (the packed form does not follow the two-step rule):
> || closure || argument || closure class || packed ||
> | \{ String s -> \} | ['four'] | s = 'four' | MissingMethodException |
> | \{ String s -> \} | [null] | s = null | MissingMethodException |
> | \{ int i -> \} | [1] | i = 1 | MissingMethodException |
> | \{ String[] a -> \} | [null], or a list holding one String[] | a = the 
> element | IllegalArgumentException |
> | \{ String[] a -> \} | [1] | MissingMethodException | 
> IllegalArgumentException |
> | \{ a, Object... b -> \} | ['four'] | a = ['four'], b = [] (the list is 
> accepted as it stands) | a = 'four', b = [] |
> | \{ List a, Object... b -> \} | ['four'] | a = ['four'], b = [] | 
> MissingMethodException |
> | \{ String a, String b -> \} | a list of a String and a GString | 
> IllegalArgumentException (the elements are passed unconverted) | binds, 
> converting the GString |
> | \{ String... a -> \}, \{ a, Object... b -> \} | null, called from dynamic 
> code | a = null | a = [] (first), MissingMethodException (second) |
> | \{ int i -> \} | null | NullPointerException | GroovyCastException |
> | \{ -> \}, \{ a, b -> \} | null | NullPointerException | 
> MissingMethodException |
> Closures whose single parameter accepts the list (Object, untyped, implicit 
> it, List, Collection, Iterable, an array of a type the list is an instance 
> of) already agree: the parameter is the list.
> Proposed fix (pull request to follow)
> In PackedClosure, destructure a single List argument exactly when the 
> signature does not accept the list as it stands 
> (ParameterTypes#isValidMethod, the test ClosureMetaClass applies), for any 
> number of parameters, and then treat the elements as ClosureMetaClass does: 
> MissingMethodException when no signature applies to them, no conversion 
> otherwise. The check sits behind the existing "argument is not an instance of 
> the parameter type" test, so a call whose argument the parameter takes 
> directly costs what it did.



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

Reply via email to