Jason Garrett created GROOVY-11027:
--------------------------------------
Summary: Boolean isProperty() method does not create synthetic
Boolean property
Key: GROOVY-11027
URL: https://issues.apache.org/jira/browse/GROOVY-11027
Project: Groovy
Issue Type: Bug
Components: Compiler
Affects Versions: 4.0.11, 4.0.10, 4.0.9
Reporter: Jason Garrett
A class that defines a Boolean (object, not primitive) method isMyProperty()
does not have the corresponding synthetic Boolean property.
The main method of this class:
{code:java}
class SyntheticBooleanProperty {
Boolean isMyProperty() {
return null
}
static void main(args) {
assert (new SyntheticBooleanProperty()).myProperty == null
}
} {code}
Fails with a MissingPropertyException:
{code:java}
Exception in thread "main" groovy.lang.MissingPropertyException: No such
property: myProperty for class: SyntheticBooleanProperty
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:67)
at
org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:161)
at
org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
at SyntheticBooleanProperty.main(SyntheticBooleanProperty.groovy:7) {code}
This does not happen if the method's return type is (primitive) boolean. It
can be worked around by adding a Boolean getMyProperty() method.
This happens with and without CompileStatic, and goes back at least as far as
version 4.0.9.
Here is a [live
demo|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJy1UbFOxDAMnclXWJ1g6e2VWECMBSRuOzH0UrcNNHGUuEcr1H8nzbVHe8x4SBQ_2--9WGlLjsFbkp9pW5g6fbMoVaVkwYqMELItvId8eIz3t4AQR6IWCwPK58OrI4uOh9u7GZzCIXfOALsOY26Mp4Cb3Q4YPYMNw9CDqoAb5UEjN1SGedAZSVqjYSxFKA7xMJPVyFdsZ3zFt9Uz46MYr1zsJwXYM5rSw8bubKHECpKocz0x2Vis1QlNdnlOsXySHl6OH3APBr-WXFCzVGEfGHnbGTtSfaGKySC_dkSn4byXXHmvTL2UPPUS7aQ5g2cC38kG7AxlsJpUkYPoPlu0_GU-JL8Nyfs_M8d9iI2IH_uGyy4].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)