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

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

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

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




> SC: compound assignment to a subscript whose getAt/putAt belong to an 
> enclosing instance fails to compile or reads the wrong object
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12820
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12820
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> On master (09e84fa), JDK 25.0.4:
> {code:groovy}
> class Box {
>     String id
>     Box(String id) { this.id = id }
>     String getAt(int i) { 'g' + id + i }
>     void putAt(int i, String v) { id = 'put(' + v + ')' }
>     @groovy.transform.CompileStatic
>     class In { def t(In other) { other[2] += 'w' } }
>     Object in() { new In() }
> }
> def a = new Box('A'), b = new Box('B')
> a.in().t(b.in())
> assert b.id == 'put(gB2w)'
> {code}
> Dynamic Groovy and {{@TypeChecked}} call {{getAt}} and {{putAt}} on 
> {{other}}'s enclosing {{Box}}. Under {{@CompileStatic}}, each of these fails 
> with GroovyBugError in class generation, at 
> {{StaticTypesCallSiteWriter.makeSingleArgumentCall}}:
> {code:groovy}
> other[2] += 'w'
> other[2]++
> other[2] ?= 'e'
> {code}
> With private {{getAt}}/{{putAt}} and an inner {{class Sub extends Box}}, the 
> code compiles, but the read uses {{getAt}} on {{other}} itself while the 
> write goes to the enclosing instance, so {{b.id}} becomes {{put(gself2w)}} 
> instead of {{put(gB2w)}}.



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

Reply via email to