Scott Murphy Heiberg created GROOVY-12524:
---------------------------------------------
Summary: 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
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)