groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jochen Theodorou (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-7511) Map literal doesn't use getter from subclass to get value
Date Tue, 21 Jul 2015 05:56:04 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-7511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jochen Theodorou resolved GROOVY-7511.
--------------------------------------
    Resolution: Won't Fix
      Assignee: Jochen Theodorou  (was: Cédric Champeau)

Property access in the same class as the property is defined in, is by design using the field
directly if available.  So there is no bug here

> Map literal doesn't use getter from subclass to get value
> ---------------------------------------------------------
>
>                 Key: GROOVY-7511
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7511
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.4
>            Reporter: César Izurieta
>            Assignee: Jochen Theodorou
>            Priority: Minor
>
> When running this code:
> {code:title=test.groovy|borderStyle=solid}
> class Test1 {
>     String x = "1"
>     Map getMap() {
>         [ key: x ]
>     }
> }
> class Test2 extends Test1 {
>     @Override
>     String getX() {
>         return "2"
>     }
> }
> assert new Test2().map.key == "2"
> {code}
> The assert fails. The reason seems to be that the {{getMap}} method doesn't call {{this.getX()}}
method but {{this.x}} directly. Using {{getX()}} instead of {{x}} works as expected.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message