You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paolo di tommaso (JIRA)" <ji...@apache.org> on 2019/05/20 20:14:00 UTC
[jira] [Created] (GROOVY-9127) Cannot set protected field from
subclass
paolo di tommaso created GROOVY-9127:
----------------------------------------
Summary: 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
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
(v7.6.3#76005)