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

Jochen Theodorou commented on GROOVY-8659:
------------------------------------------

I think we should change the logic for the getter and setter and require them 
to be provided in the same class as the property. In Java it is perfectly legal 
to declare a public field prop in Foo and then again declare the same field in 
Bar which extends Foo. I actually never understood why this is the case for 
non-private fields, but it is as it is... just we cannot do the same for 
properties.

> 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
(v7.6.3#76005)

Reply via email to