[
https://issues.apache.org/jira/browse/GROOVY-12659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140642#comment-18140642
]
ASF GitHub Bot commented on GROOVY-12659:
-----------------------------------------
testlens-app[bot] commented on PR #3180:
URL: https://github.com/apache/groovy/pull/3180#issuecomment-6719710240
## 🚨 Jobs failed without executing tests 🚨
### Failed Jobs without Test Failures
❌ [Generate SNAPSHOT artifacts /
dist](https://github.com/apache/groovy/actions/runs/42466428770/job/128686907112?pr=3180)
❌ [Generate SNAPSHOT distributions /
dist](https://github.com/apache/groovy/actions/runs/42466428550/job/128686906346?pr=3180)
🏷️ Commit: 9f14020ba22be96110543a468d11c88e96ade806
▶️ Tests: 0 executed
🟡 Checks: 4/24 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> Closure packing packs a closure literal that escapes through a ternary, an
> elvis or a curry/asWritable/clone call
> -----------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12659
> URL: https://issues.apache.org/jira/browse/GROOVY-12659
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> class Holder { Closure handler }
> @groovy.transform.PackedClosures
> class C {
> void install(Holder h, boolean b) { h.handler = b ? { Integer x -> x + 1
> } : null }
> Closure make() { return { Integer x, Integer y -> x + y }.curry(1) }
> }
> def h = new Holder()
> new C().install(h, true)
> h.handler.delegate = 'd'
> new C().make().delegate = 'd'
> {code}
> *Actual:* both delegate assignments throw {{UnsupportedOperationException:
> Cannot set a delegate on a @PackedClosures closure}}. The same happens for an
> elvis and for a literal behind rcurry, ncurry, asWritable, clone, dehydrate
> or rehydrate, when the result is stored to a field, property or index,
> appended with {{<<}}, returned, or placed in a list or map literal.
> *Expected:* the literal is declined from packing, as it is when it is itself
> the stored or returned value, and the delegate can be set.
> Cause: the escape walk in {{ClosureWriter.collectEscapingClosures}} marks a
> literal only when it is the escaping expression itself. It does not follow
> the value through ternary and elvis branches, through casts, or into the
> curried or wrapped closure. CurriedClosure and the asWritable wrapper pass
> setDelegate on to the packed closure, and clone, dehydrate and rehydrate
> return a packed copy.
> Verified on 6.0.0 and master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)