[ 
https://issues.apache.org/jira/browse/GROOVY-11376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-11376.
------------------------------

> 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: 4.0.0, 5.0.0-alpha-8
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-9
>
>
> 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-6954, GROOVY-11367



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to