groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-8728) Verifier.addDefaultParameters erases metadata if run more than once
Date Mon, 06 Aug 2018 14:25:00 GMT

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

Paul King resolved GROOVY-8728.
-------------------------------
       Resolution: Fixed
         Assignee: Paul King
    Fix Version/s: 2.5.2

> Verifier.addDefaultParameters erases metadata if run more than once
> -------------------------------------------------------------------
>
>                 Key: GROOVY-8728
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8728
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.15, 2.5.1
>            Reporter: Eric Milles
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 2.5.2
>
>
> When processing sources with closure with parameter defaults, {{Verifier}} is wiping
out the node metadata that contains the initial value expression.  At the end of {{addDefaultParameters(DefaultArgsAction
action, MethodNode method)}}, there is a for loop:
> {code:java}
>         for (Parameter parameter : parameters) {
>             // GRECLIPSE add
>             if (!parameter.hasInitialExpression()) continue;
>             // GRECLIPSE end
>             // remove default expression and store it as node metadata
>             parameter.putNodeMetaData(Verifier.INITIAL_EXPRESSION, parameter.getInitialExpression());
>             parameter.setInitialExpression(null);
>         }
> {code}
> This loop currently moves the initial expression to node metadata.  However, when this
method runs a second time, it takes null from {{getInitialExpression}} and puts that as the
new metadata value, even if the node already has been processed.
> Adding a check {{hasInitialExpression}} solves this issue, making {{addDefaultParameters}}
idempotent.  This also prevent adding the metadata value in the first place for a parameter
that never had a default value expression.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message