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

ASF GitHub Bot commented on GROOVY-12520:
-----------------------------------------

paulk-asert merged PR #3046:
URL: https://github.com/apache/groovy/pull/3046




> super.x calls getX() instead of isX() when the class overrides isX()
> --------------------------------------------------------------------
>
>                 Key: GROOVY-12520
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12520
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> When a class declares both {{isX()}} and {{getX()}}, Groovy reads the 
> property {{x}} through {{isX()}} (GROOVY-10133), also through {{super}}. If 
> the subclass overrides {{isX()}} or declares a {{boolean x}} property, 
> dynamic Groovy and {{@TypeChecked}} read {{super.x}} through the superclass's 
> {{getX()}} instead:
> {code:groovy}
> class C {
>     boolean isX() { true }
>     boolean getX() { false }
> }
> class D extends C {
>     boolean isX() { false }
>     boolean test() { super.x }
> }
> class E extends C {
>     boolean x
>     boolean test() { super.x }
> }
> assert new D().test() // fails: false
> assert new E().test() // fails: false
> {code}
> {{@CompileStatic}} returns {{true}} for both, and so does dynamic Groovy 
> 4.0.33. 5.0.0, 5.0.8, 6.0.0 and master return {{false}}.
> For {{super}}, the getter of an overridden method is the MOP method 
> {{super$2$isX}}, and the check that keeps {{isX()}} over {{getX()}} only 
> accepts a method whose name starts with "is", so {{getX()}} replaces it.
> Expected: {{super.x}} calls {{C.isX()}} in every mode.
> PR: https://github.com/apache/groovy/pull/3046



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to