[
https://issues.apache.org/jira/browse/GROOVY-12840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152311#comment-18152311
]
ASF GitHub Bot commented on GROOVY-12840:
-----------------------------------------
codecov-commenter commented on PR #3368:
URL: https://github.com/apache/groovy/pull/3368#issuecomment-7234065101
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3368?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 74.9765%. 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
([`3eb9bf8`](https://app.codecov.io/gh/apache/groovy/commit/3eb9bf8ce5b299c750c2458d525f15a7b629499a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/3368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3368 +/- ##
==================================================
- Coverage 74.9810% 74.9765% -0.0045%
+ Complexity 48992 48989 -3
==================================================
Files 1768 1768
Lines 161397 161400 +3
Branches 31782 31783 +1
==================================================
- Hits 121017 121012 -5
- Misses 28949 28953 +4
- Partials 11431 11435 +4
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3368?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...rg/codehaus/groovy/classgen/asm/ClosureWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3368?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FClosureWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9DbG9zdXJlV3JpdGVyLmphdmE=)
| `89.3528% <100.0000%> (+0.0334%)` | :arrow_up: |
... and [9 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3368/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>
> Closure packing declines a closure that reads a parameter or local variable
> named owner, delegate or thisObject
> ---------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12840
> URL: https://issues.apache.org/jira/browse/GROOVY-12840
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 6.0.0, 6.0.1
> Reporter: Scott Murphy Heiberg
> Priority: Blocker
>
> The packability analysis (ClosureWriter#isPackable) keeps a closure as a
> class when its body names one of the Closure pseudo-properties: owner,
> delegate, thisObject, directive, resolveStrategy, metaClass. The test is on
> the name of every VariableExpression alone, so it also declines a closure
> that reads a method parameter or a local variable of that name. Such a
> variable hides the Closure property in a closure class too, so the body does
> not use the property and nothing prevents packing it.
> {code:groovy}
> import groovy.transform.CompileStatic
> import groovy.transform.PackedClosures
> @CompileStatic
> @PackedClosures
> class OwnerName {
> static String greet(String owner, List<String> pets) {
> Closure<String> c = { String pet -> owner + ' owns ' + pet }
> println c.getClass().name
> pets.collect(c).join(', ')
> }
> static String other(String name, List<String> pets) {
> Closure<String> c = { String pet -> name + ' owns ' + pet }
> println c.getClass().name
> pets.collect(c).join(', ')
> }
> static void main(String[] args) {
> println greet('Ann', ['Rex'])
> println other('Ann', ['Rex'])
> }
> }
> {code}
> Actual (6.0.0, 6.0.1 and master, 7.0.0-SNAPSHOT):
> {noformat}
> OwnerName$_greet_closure1
> Ann owns Rex
> org.codehaus.groovy.runtime.PackedClosure$Fixed1
> Ann owns Rex
> {noformat}
> Expected: both closures packed (PackedClosure$Fixed1 twice). The results are
> right either way; the cost is a closure class that need not exist, a warning
> with @PackedClosures(mode = WARN) or groovy.target.closure.pack.report, and a
> compile error with @PackedClosures(mode = STRICT), whose message says the
> closure "needs a real Closure (uses
> owner/delegate/thisObject/resolveStrategy/super or metaClass, ...)" although
> it uses none of them. The same with dynamic compilation.
> Proposed fix (pull request to follow)
> In the visitVariableExpression of ClosureWriter#isPackable, decline for one
> of those names only when the expression's accessed variable is not a
> Parameter or a declared local variable (a VariableExpression). A name bound
> to a field or property of the enclosing class, or to nothing, still reads the
> Closure property in a closure class and keeps declining.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)