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

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

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

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 765c503ce7e6be6aa0da332e771e1f804015cf3e
   ▶️ Tests:  127211 executed
   ⚪️ Checks: 26/26 completed
   
   ---
   _Learn more about TestLens at 
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   




> Closure packing copies a local written after the literal by value in a 
> constructor or instance initializer block
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12653
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12653
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 7.0.0-alpha-1, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> With closure packing enabled ({{-Dgroovy.target.closure.pack=true}} or 
> {{@PackedClosures}}), a local captured by a closure literal in a constructor 
> or an instance initializer block, and written after the literal, is copied 
> into the packed closure by value instead of shared:
> {code:groovy}
> class R { def r; R() { def c; c = { x -> c == null ? 'stale' : 'set' }; r = 
> c(1) }
>           def m() { def c; c = { x -> c == null ? 'stale' : 'set' }; c(1) } }
> class I { def r; { def c; c = { x -> c == null ? 'stale' : 'set' }; r = c(1) 
> } }
> [new R().r, new R().m(), new I().r]
> {code}
> *Actual* (dynamic and @CompileStatic, packing on): {{[stale, set, stale]}}.
> *Expected:* {{[set, set, set]}}, as without packing and as in a method.
> Cause: the lookup of names written after the literal 
> ({{ClosureWriter.holderCaptureNames}}) uses 
> {{WriterController.getMethodNode()}}, which is null while a constructor is 
> written, so no capture is threaded as a shared Reference.



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

Reply via email to