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

Eric Milles reassigned GROOVY-9127:
-----------------------------------

    Assignee: Eric Milles  (was: Daniel Sun)

> 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: Eric Milles
>            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