Eric Milles created GROOVY-11376:
------------------------------------
Summary: SC: put entry replaced write field for public and
protected of map-based type
Key: GROOVY-11376
URL: https://issues.apache.org/jira/browse/GROOVY-11376
Project: Groovy
Issue Type: Bug
Components: Static compilation
Affects Versions: 5.0.0-alpha-8, 4.0.0
Reporter: Eric Milles
Assignee: Eric Milles
Consider the following:
{code:groovy}
class M implements Map<String,Object> {
@Delegate Map<String,Object> map = [:].withDefault{ 'entry' }
public a = 'field'
protected b = 'field'
@PackageScope c = 'field'
private d = 'field'
Closure e = { 'callable' }
}
@groovy.transform.CompileStatic
void test(M map) {
map.a = null // SC: 6549 (Groovy 4+)
map.b = null // SC: 6549 (Groovy 4+)
map.c = null
map.d = null
map.e = null
println map // expect: [c:null, d:null]
}
test(new M())
{code}
Running this script prints "[a: null, b: null, c: null, d: null]" since Groovy
4. The prior behavior was to write to public and protected fields, which is
the behavior you get if you disable static compilation.
GROOVY-6549, GROOVY-11367
--
This message was sent by Atlassian Jira
(v8.20.10#820010)