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

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

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

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




> Packed closures read and write owner properties as fields, skipping getters 
> and setters
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12658
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12658
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> A closure packed by closure packing (GEP-27, via {{@PackedClosures}} or 
> {{-Dgroovy.target.closure.pack=true}}) has its body moved into a method of 
> the owner class. There, a property of the owner compiles to direct field 
> access, so the getter and setter are no longer called. The closure class it 
> replaces calls them.
> {code:groovy}
> @groovy.transform.CompileStatic // or @groovy.transform.PackedClosures 
> without @CompileStatic
> @groovy.transform.PackedClosures
> class Box {
>     int gets, sets
>     BigDecimal e = 1
>     BigDecimal getE() { gets++; e }
>     void setE(BigDecimal v) { sets++; e = v }
>     def m() { def r = { -> e++ }(); [r, this.@e, gets, sets] }
> }
> println new Box().m()
> {code}
> *Actual:* {{[1, 2, 0, 0]}}
> *Expected:* {{[1, 2, 1, 1]}}, as without packing.
> The same happens for reads, assignments, compound assignments, prefix and 
> postfix forms, and both {{e}} and {{this.e}}. It also affects a subclass 
> override of a generated accessor, static properties, {{is}} getters, and 
> (dynamic) an owner that overrides {{getProperty}}. 
> {{AsmClassGenerator.visitPropertyExpression}} resolves {{this.name}} to the 
> declared field in any method of the class; the hoisted body is such a method, 
> so it bypasses the accessors.
> Verified on 6.0.0 and master.



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

Reply via email to