Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0, 5.0.0-alpha-8
-
None
Description
Consider the following:
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())
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.
Attachments
Issue Links
- is related to
-
GROOVY-6954 map.foo = "bar" not optimized by the static compiler
- Closed