[
https://issues.apache.org/jira/browse/GROOVY-12524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18133571#comment-18133571
]
ASF GitHub Bot commented on GROOVY-12524:
-----------------------------------------
daniellansun opened a new pull request, #3064:
URL: https://github.com/apache/groovy/pull/3064
https://issues.apache.org/jira/browse/GROOVY-12524
> SC: a compound assignment to a property defined by extension methods fails
> with "Access to ... is forbidden"
> ------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12524
> URL: https://issues.apache.org/jira/browse/GROOVY-12524
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> Under {{@CompileStatic}}, a compound assignment to a property whose accessors
> are extension methods does not compile:
> {code:groovy}
> @groovy.transform.CompileStatic
> class C {
> String test(File file) {
> file.text += 'b' // Access to java.io.File#text is forbidden
> file.text
> }
> }
> {code}
> Reading {{file.text}} and assigning {{file.text = 'b'}} compile to direct
> calls of the extension methods {{getText(File)}} and {{setText(File,
> String)}}, and dynamic Groovy and {{@TypeChecked}} run the compound
> assignment. The same error is reported for {{this.text += 'b'}} and {{text +=
> 'b'}} in a subclass of {{File}}. Seen in 4.0.33, 5.0.8, 6.0.0 and master.
> Expected: the compound assignment compiles to calls of the extension methods,
> like the read and the plain assignment.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)