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 2022/02/23 00:00:00 UTC

[jira] [Resolved] (GROOVY-10502) NamedVariant: improve consistency of default value treatment

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

Paul King resolved GROOVY-10502.
--------------------------------
    Fix Version/s: 4.0.1
         Assignee: Paul King
       Resolution: Fixed

Proposed PR merged.

> NamedVariant: improve consistency of default value treatment
> ------------------------------------------------------------
>
>                 Key: GROOVY-10502
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10502
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.0
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>              Labels: named-parameters
>             Fix For: 4.0.1
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> When adjusting NamedVariant to cater for its use (under the covers) for records, a few anomalies were introduced. The first is fixed in GROOVY-10497. This one covers a left over case for null.
> For this method:
> {code:groovy}
> def x(int one, int two = 42) { "$one $two" }
> {code}
> Calling any of the following will fail with a MissingMethodException:
> {code:groovy}
> x(null)
> x(null, 3)
> x(3, null)
> {code}
> When NamedVariant is applied, e.g.
> {code:groovy}
> @groovy.transform.NamedVariant
> def m(int one, int two = 42) { "$one $two" }
> {code}
> Then all of the following succeed:
> {code:groovy}
> m(one:null) // 0 42
> m(one:null, two:null) // 0 42
> m(one:32, two:null) // 32 42
> m(one:null, two:52) // 0 52
> {code}
> When null is encountered, we supply either the explicit or implicit default value. The purpose of this issue is to revert the behavior of this edge case to more traditional behavior, so the previous calls would all give a MissingMethodException.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)