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

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

codecov-commenter commented on PR #3367:
URL: https://github.com/apache/groovy/pull/3367#issuecomment-7234129185

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3367?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `87.71930%` with `7 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 75.0060%. Comparing base 
([`d108274`](https://app.codecov.io/gh/apache/groovy/commit/d108274c11dda1f125e157d221fd0dcc27883fd8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`4268ed9`](https://app.codecov.io/gh/apache/groovy/commit/4268ed9dd43a95dfb5d1c00e55e67a9fb8a95b53?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3367?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...ava/org/codehaus/groovy/runtime/PackedClosure.java](https://app.codecov.io/gh/apache/groovy/pull/3367?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2FPackedClosure.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvUGFja2VkQ2xvc3VyZS5qYXZh)
 | 87.7193% | [0 Missing and 7 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3367/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/3367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3367        +/-   ##
   ==================================================
   + Coverage     74.9810%   75.0060%   +0.0251%     
   - Complexity      48992      49047        +55     
   ==================================================
     Files            1768       1768                
     Lines          161397     161443        +46     
     Branches        31782      31802        +20     
   ==================================================
   + Hits           121017     121092        +75     
   + Misses          28949      28924        -25     
   + Partials        11431      11427         -4     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3367?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...ava/org/codehaus/groovy/runtime/PackedClosure.java](https://app.codecov.io/gh/apache/groovy/pull/3367?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2FPackedClosure.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvUGFja2VkQ2xvc3VyZS5qYXZh)
 | `76.3393% <87.7193%> (+13.4179%)` | :arrow_up: |
   
   ... and [13 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3367/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> 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