You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/01/03 20:08:00 UTC

[jira] [Resolved] (GROOVY-10889) Casting of arguments in @NamedVariant method has no effect

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

Eric Milles resolved GROOVY-10889.
----------------------------------
    Resolution: Fixed

https://github.com/apache/groovy/commit/1516992472d5304449d2d6659af525305f5c6dc8

> Casting of arguments in @NamedVariant method has no effect
> ----------------------------------------------------------
>
>                 Key: GROOVY-10889
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10889
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.6
>            Reporter: Pavlo Shevchenko
>            Assignee: Eric Milles
>            Priority: Minor
>              Labels: named-parameters
>
> {code:java}
> import groovy.transform.NamedVariant
> class Reproducer {
>     @NamedVariant
>     private static Tuple2<Integer, Set<String>> createSampleData(
>         Integer left = 0,
>         Set<String> right = [] as Set
>     ) {
>         Tuple2.tuple(left, right)
>     }
>     static void main(String[] args) {
>         createSampleData(left: 1)
>     }
> }
> {code}
> The default value of "right" argument (i.e. "[] as Set") is detected as "ArrayList" despite the explicit cast. This used to work in Groovy 3.x, and now fails with
> {code:java}
> Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static dev.pshevche.Reproducer.createSampleData() is applicable for argument types: (Integer, ArrayList) values: [1, []]{code}
> Replacing the "[] as Set" with "new HashSet<>()" resolves the issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)