[
https://issues.apache.org/jira/browse/GROOVY-12655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140648#comment-18140648
]
ASF GitHub Bot commented on GROOVY-12655:
-----------------------------------------
testlens-app[bot] commented on PR #3176:
URL: https://github.com/apache/groovy/pull/3176#issuecomment-6719729350
## 🚨 Jobs failed without executing tests 🚨
### Failed Jobs without Test Failures
❌ [CodeQL / Analyze \(java,
21\)](https://github.com/apache/groovy/actions/runs/42466427787/job/128686903639?pr=3176)
❌ [Generate SNAPSHOT artifacts /
dist](https://github.com/apache/groovy/actions/runs/42466427810/job/128686903740?pr=3176)
❌ [Generate SNAPSHOT distributions /
dist](https://github.com/apache/groovy/actions/runs/42466427788/job/128686903647?pr=3176)
🏷️ Commit: 9c5e0c61ef0e5bf55263c75458ed487a646f4363
▶️ Tests: 0 executed
🟡 Checks: 6/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 stored to a script binding variable or
> dynamic property, which then rejects a delegate
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12655
> URL: https://issues.apache.org/jira/browse/GROOVY-12655
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> @groovy.transform.PackedClosures
> def install() { handler = { x -> x + 1 } }
> install()
> handler.delegate = 'd'
> handler(1)
> {code}
> *Actual:* {{java.lang.UnsupportedOperationException: Cannot set a delegate on
> a @PackedClosures closure (hoisted method '$packed$closure$0') ...}}
> *Expected:* the closure is not packed, because it escapes into the script
> binding, and the script returns 2 as it does without the annotation.
> The same happens when a method of an annotated class stores to an undeclared
> name (a dynamic property, e.g. one taken by {{propertyMissing}}) and when a
> script method stores to an {{@Field}}. With
> {{-Dgroovy.target.closure.pack=true}}, a binding store in a script's run
> method is packed too, and so is one in {{@CompileStatic}} code whose type
> checking extension makes the variable dynamic.
> Cause: the escape gate in {{ClosureWriter}} ({{isLocalTarget}}) treats any
> assignment target that is not a field or property node as a local, including
> a {{DynamicVariable}}, which is stored through the MOP where code outside the
> method can read it.
> Verified on 6.0.0 and master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)