You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/07/28 11:50:00 UTC
[jira] [Commented] (GROOVY-10707) Regression in property access for conflicting isXxx and getXxx accessors
[ https://issues.apache.org/jira/browse/GROOVY-10707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17572401#comment-17572401 ]
Eric Milles commented on GROOVY-10707:
--------------------------------------
This change was intended and marked as breaking. There are lengthy discussions of the change, its motivations and its ramifications. I think Node firstChild is the one case that is going to be the biggest offender.
> Regression in property access for conflicting isXxx and getXxx accessors
> ------------------------------------------------------------------------
>
> Key: GROOVY-10707
> URL: https://issues.apache.org/jira/browse/GROOVY-10707
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.3
> Reporter: Kyle Moore
> Priority: Major
>
> In upgrading our codebase from Groovy 3.0.11 to 4.0.3, we noticed a regression in method selection when using property access. This toy example illustrates the issue:
> {code:java}
> class Base {
> boolean isFirstChild() { return true }
> }
> class Sub extends Base {
> String getFirstChild() { return "hello" }
> }
> class SubSub extends Sub { }
> assert new SubSub().firstChild instanceof String
> {code}
>
> This code passes in Groovy 3 but fails in Groovy 4. We observed this real-world behavior with {{xerces:xercesImpl:2.12.1}} where an instance of class {{org.apache.xerces.dom.ParentNode}} has both methods {{getFirstChild()}} returning a {{Node}} and {{isFirstChild()}} returning a {{boolean}}.
> As a workaround, we can access {{getFirstChild()}} by name instead of using property access, but in discussions with [~paulk] this behavior change may be unintended.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)