[
https://issues.apache.org/jira/browse/GROOVY-5357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17111560#comment-17111560
]
OC commented on GROOVY-5357:
----------------------------
I might be missing something of importance, but by my own testing, this seems
to be fixed in both 3.0.3 and 4.0.0_S. Shouln't the ticket be closed?
> The accessor pair can't be provided from different sources
> ----------------------------------------------------------
>
> Key: GROOVY-5357
> URL: https://issues.apache.org/jira/browse/GROOVY-5357
> Project: Groovy
> Issue Type: Sub-task
> Components: groovy-runtime
> Reporter: OC
> Priority: Major
>
> When one of the accessor pair is added through a mixin or metaclass, Groovy
> behaves as if the other one did not exist.
> Explanation kindly provided by Paul: "MetaClassImpl finds a MetaBeanProperty
> containing just the getter. When only a getter is found there is an incorrect
> assumption that a setter doesn't exist in the underlying class."
> {code}
> class Foo {
> void setVal(v) { println "setVal: $v" }
> }
> @Category(Foo) class Getter {
> def getVal() { println "getVal" }
> }
> class Test {
> static def main(av) {
> Foo.mixin Getter
> def f = new Foo()
> f.setVal('foo')
> f.val = null // => groovy.lang.ReadOnlyPropertyException: Cannot set
> readonly property: val for class: Foo
> }
> }
> {code}
> or
> {code}
> class Foo {
> void setVal(v) { println "setVal: $v" }
> }
> class Test {
> static def main(av) {
> Foo.metaClass.getVal={-> println "getval" }
> def f = new Foo()
> f.setVal('foo')
> f.val = null // => groovy.lang.ReadOnlyPropertyException: Cannot set
> readonly property: val for class: Foo
> }
> }
> {code}
> or
> {code}
> class Foo {
> def getVal() { println "getVal" }
> }
> class Test {
> static def main(av) {
> Foo.metaClass.setVal={v-> }
> def f = new Foo()
> f.getVal()
> f.val
> }
> }
> {code}
> etc.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)