You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/02/01 23:19:08 UTC

[jira] [Closed] (GROOVY-5752) DelegateASTTransformation#addGetterIfNeeded doesn't take boolean isX accessors into account

     [ https://issues.apache.org/jira/browse/GROOVY-5752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-5752.
-----------------------------

> DelegateASTTransformation#addGetterIfNeeded doesn't take boolean isX accessors into account
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-5752
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5752
>             Project: Groovy
>          Issue Type: Bug
>          Components: xforms
>    Affects Versions: 2.0.5, 2.4.0-rc-1
>            Reporter: Joris Kuipers
>            Assignee: Paul King
>             Fix For: 2.4.8
>
>
> I'm using @Delegate on a field whose type includes boolean properties. The resulting byte code properly delegates non-overridden getters and setters, but not boolean isX() accessors. This is due to DelegateASTTransformation#addGetterIfNeeded not considering isX accessors. 
> Right now I've fixed this like this, wrapping the existing method in a for loop iterating over both 'get' and 'is':
> {code}
>     private void addGetterIfNeeded(FieldNode fieldNode, ClassNode owner, PropertyNode prop, String name) {
>     	for (String accessor: new String[] {"get", "is"}) {
>     		String getterName = accessor + Verifier.capitalize(name);
>     		if (owner.getGetterMethod(getterName) == null) {
>     			owner.addMethod(getterName,
>     					ACC_PUBLIC,
>     					nonGeneric(prop.getType()),
>     					Parameter.EMPTY_ARRAY,
>     					null,
>     					new ReturnStatement(
>     							new PropertyExpression(
>     									new VariableExpression(fieldNode),
>     									name)));
>     		}
>     	}
>     }
> {code}
> I could include a JUnit test, but the bug seems obvious enough looking at the DelegateASTTransformation code.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)