You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/12/22 11:39:00 UTC
[jira] [Closed] (GROOVY-3855) Overridden property getter via metaclass is not used for subclasses
[ https://issues.apache.org/jira/browse/GROOVY-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-3855.
-----------------------------
> Overridden property getter via metaclass is not used for subclasses
> -------------------------------------------------------------------
>
> Key: GROOVY-3855
> URL: https://issues.apache.org/jira/browse/GROOVY-3855
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 1.7-beta-2
> Environment: osx
> Reporter: Rob Nielsen
> Priority: Minor
> Attachments: PropertyAccessFromSubclassTests.groovy
>
>
> Getter methods for properties can by overridden with
> {code}
> class A { String one }
> A.metaClass.getOne = {
> return "one"
> }
> {code}
> and this is used for access with {{a.one}} and {{a.getOne()}}. If the class is subclassed like
> {code}
> class B extends A
> {code}
> then {{b.getOne()}} uses the new method but {{b.one}} directly accesses the field.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)