Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.2
-
None
-
None
Description
When accessing a non-final property through a @Delegate as below, a ReadOnlyPropertyException is thrown.
class DelegateTests extends GroovyTestCase { void testNonFinalPropertiesCanBeSet() { def foo = new Foo() foo.baz = "baz" assert foo.baz == "baz" } } class Foo { @Delegate Bar bar = new Bar() } class Bar { String baz }
groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: baz for class: test.Foo at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2406) at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3307) at test.Foo.setProperty(DelegateTests.groovy) at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:179) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:483) at test.DelegateTests.testNonFinalPropertiesCanBeSet(DelegateTests.groovy:11)