Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Duplicate
-
4.0.9, 4.0.10, 4.0.11
-
None
-
None
Description
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:
class SyntheticBooleanProperty { Boolean isMyProperty() { return null } static void main(args) { assert (new SyntheticBooleanProperty()).myProperty == null } }
Fails with a MissingPropertyException:
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)
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.