[
https://issues.apache.org/jira/browse/GROOVY-12820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149423#comment-18149423
]
ASF GitHub Bot commented on GROOVY-12820:
-----------------------------------------
testlens-app[bot] commented on PR #3331:
URL: https://github.com/apache/groovy/pull/3331#issuecomment-7085935045
## ✅ All tests passed ✅
🏷️ Commit: 5558a01f283ffccd3e364f3e66ebcca9029814bd
▶️ Tests: 407 executed
⚪️ Checks: 24/24 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)