Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Information Provided
-
4.0.3
-
None
-
None
-
None
Description
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:
class Base { boolean isFirstChild() { return true } } class Sub extends Base { String getFirstChild() { return "hello" } } class SubSub extends Sub { } assert new SubSub().firstChild instanceof String
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.
Attachments
Issue Links
- is related to
-
GROOVY-7300 CompileStatic doesn't call property accessors on super classes correctly
- Closed
-
GROOVY-10462 Groovy should not generate both `getFlag` and `isFlag` for a Boolean field.
- Closed
-
GROOVY-1736 Accessing superclass properties causes stack overflow
- Closed
-
GROOVY-5245 Inconsistency with accessing issers as properties
- Closed
-
GROOVY-6097 Using super.propertyName gives a MissingMethodException when the property is a boolean and uses the "isPropertyName" naming convention.
- Closed
-
GROOVY-9382 Inconsistent support for [Bb]oolean properties
- Closed
-
GROOVY-10133 Inconsistent method selection for [Bb]oolean properties
- Closed
-
GROOVY-7924 groovyc fails with NPE for dynamic method/property use on super
- Closed
- relates to
-
GROOVY-10821 Potential regression for isser/getter preference in classes with an isser and a not boolean getter for a property of the same name
- Closed