[ https://issues.apache.org/jira/browse/GROOVY-9292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16961112#comment-16961112 ]
Eric Milles commented on GROOVY-9292: ------------------------------------- Is this an "Access is forbidden" compilation error? Can you explain why enabling dynamic property is the chosen solution? I still don't understand the implications of making these cases dynamic instead of finding where the access checks are. > Compilation error when accessing a protected field from a closure using > owner, delegate or thisObject qualifier > --------------------------------------------------------------------------------------------------------------- > > Key: GROOVY-9292 > URL: https://issues.apache.org/jira/browse/GROOVY-9292 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.5.8, 3.0.0-rc-1 > Reporter: Daniel Sun > Assignee: Daniel Sun > Priority: Major > > Compilation fails when accessing a protected(via `thisObject`, `owner` and > `delegate`)/package-private super class field from inside a closure: > {code:java} > new GroovyShell().with { > evaluate ''' > package a > > abstract class Abstract { > protected String protectedField = 'field' // `@PackageScope` fails too > > abstract String doThing() > } > assert true > ''' > evaluate ''' > package b > > @groovy.transform.CompileStatic > class Concrete extends a.Abstract { > > @Override > String doThing() { > 'something'.with { > return owner.protectedField // `thisObject.protectedField`, > `delegate.protectedField` fails too > } > } > } > assert true > ''' > evaluate 'assert new b.Concrete().doThing() == "field"' > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)