[ 
https://issues.apache.org/jira/browse/GROOVY-9127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17584978#comment-17584978
 ] 

Eric Milles edited comment on GROOVY-9127 at 8/25/22 6:39 PM:
--------------------------------------------------------------

https://github.com/apache/groovy/commit/47821d27aaa6d3a36a352ce54370d5aa4ad1441c


was (Author: emilles):
rework: 
https://github.com/apache/groovy/commit/47821d27aaa6d3a36a352ce54370d5aa4ad1441c

> Cannot set protected field from subclass
> ----------------------------------------
>
>                 Key: GROOVY-9127
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9127
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.6
>            Reporter: paolo di tommaso
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 3.0.0-beta-2
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Consider the following code 
> {code}
> @CompileStatic
> abstract class Foo {
>     protected String field1
>     String getField1() {
>         field1
>     }
> }
> @CompileStatic
> class Bar extends Foo {
>     void changeField1()  {
>         this.field1 = 'foo'
>     }
>     @Override
>     String getField1() { return 'bar command' }
> }
> {code}
> It fails to compile with the following error message: 
> {code}
> [Static type checking] - Cannot set read-only property: field1
>  @ line 29, column 9.
>            this.field1 = 'foo'
>            ^
> {code}
> Which does not make much sense to me because protected field should be 
> accessible to subclasses by definition. Tested also with 2.5.8-SNAPSHOT 
> reporting the same issue.



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

Reply via email to