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 2021/04/01 07:14:00 UTC

[jira] [Commented] (GROOVY-8659) Base class has final getter; extending class has property of same name; no warning for final override

    [ https://issues.apache.org/jira/browse/GROOVY-8659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17312930#comment-17312930 ] 

Paul King commented on GROOVY-8659:
-----------------------------------

The documentation has now been clarified to indicate the existing behavior. This issue remains open in case we wish to actually prohibit the definition of any overrides for the backing field - since the inherited getter methods will never access such fields.

> Base class has final getter; extending class has property of same name; no warning for final override
> -----------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8659
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8659
>             Project: Groovy
>          Issue Type: Question
>            Reporter: Eric Milles
>            Priority: Major
>
> Possibly related to GROOVY-8188, this is more of a question than a bug at this point.  Should it be an error to have a class extend another with a final method and provide a property of the same name?
> {code:groovy}
> class Foo {
>   final Object getProp() {}
> }
> class Bar extends Foo {
>   Object prop = 0; // Should this be a similar error?
>   //Object getProp() {} // would be "You are not allowed to override the final method getProp() from class 'Foo'."
> }
> {code}
> Executing {{new Bar().prop}} returns null (from the final method); {{new Bar().@prop}} returns 0.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)