groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Milles (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8659) Base class has final getter; extending class has property of same name; no warning for final override
Date Fri, 22 Jun 2018 00:34:00 GMT
Eric Milles created GROOVY-8659:
-----------------------------------

             Summary: 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


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)

Mime
View raw message