codeconsole opened a new pull request, #3046:
URL: https://github.com/apache/groovy/pull/3046
When a superclass declares both `isX()` and `getX()`, the property `x` is
read through `isX()` (GROOVY-10133). In a class that overrides `isX()` or
declares a `boolean x` property, `super.x` called `getX()` instead, in dynamic
Groovy and under `@TypeChecked`. It now calls `isX()`, as `@CompileStatic`,
`this.x` and Groovy 4.0.33 do. This is a regression in 5.0.0.
```groovy
class C {
boolean isX() { true }
boolean getX() { false }
}
class D extends C {
boolean isX() { false }
boolean test() { super.x } // false (getX); now true (C.isX), as in
4.0.33
}
```
Split out of #3044.
## How
For `super` usage, the getter of a method the subclass overrides is the MOP
method `super$N$isX`. The check that keeps `isX()` over `getX()` only accepted
names starting with `is`, so `getX()` replaced it. The check now looks past the
MOP prefix. The order in which the accessors are indexed changed in 5.0.0,
which is why 4.0.33 was not affected.
## Tests
`bugs.Groovy10133`, for an overriding `isX()` and for a `boolean x`
property, in all three modes, and in a closure in dynamic Groovy and under
`@TypeChecked`. They fail without the change. 14,936 tests in the `groovy`,
`gls`, `bugs`, `org.codehaus.groovy.classgen`, `transform`, `runtime`,
`reflection`, `vmplugin`, `control` and `ast` packages and the stub generator
tests pass. `groovy-contracts`, `groovy-typecheckers`, `groovy-ginq`,
`groovy-macro-library`, `groovy-json`, `groovy-xml` and `groovy-templates` pass
their tests, and every subproject compiles its main and test sources. The
Checkstyle and CodeNarc gates pass.
Being a regression in 5.0.0, this may be worth backporting to `GROOVY_5_0_X`
and `GROOVY_6_0_X`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]