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 2022/02/16 17:04:00 UTC

[jira] (GROOVY-10176) @NamedVariant with primitives can't find method

    [ https://issues.apache.org/jira/browse/GROOVY-10176 ]


    Eric Milles deleted comment on GROOVY-10176:
    --------------------------------------

was (Author: emilles):
https://github.com/apache/groovy/pull/1686

> @NamedVariant with primitives can't find method
> -----------------------------------------------
>
>                 Key: GROOVY-10176
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10176
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.14, 3.0.8
>            Reporter: Leonard Brünings
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: named-parameters
>
> When using {{@NamedVariant}} on a method that uses primitives, it cannot invoke the underlying method.
>  
> {code:java}
> import groovy.transform.NamedVariant
> @NamedVariant
> def foo(String a = 'a', int b = 1, long c = 2L) {
>  "$a-$b-$c"
> }
> assert foo(b: 2) == "a-2-2"
> {code}
>  
> You can also try it directly in the new [Groovy Console|https://gwc-experiment.appspot.com/?codez=eJxVjc0KwjAQhO_7FEMI1EJTMEeh4AOIF8H79peAzZZNEER8d6Pgwe80wwwzYd1EMxYVuT_arBzTLLq2Z16n8coaOGai458dpxmzyO6SNcQFjA4VVw1CzOiL2Te4SQmGov2pxpNQMJad7Z0dDL2IOKWp_H5m-gN8ja6DYeedN_St_3gDo98tiw].
> {noformat}
> groovy.lang.MissingMethodException: No signature of method: Script1.foo() is applicable for argument types: (null, Integer, null) values: [null, 2, null]
> Possible solutions: foo(), foo(java.lang.String, int), foo(java.lang.String, int, long), foo(java.lang.String), foo(java.util.Map), run()
> 	at Script1.foo(Script1.groovy)
> 	at Script1$foo.callCurrent(Unknown Source)
> 	at Script1.run(Script1.groovy:8) {noformat}



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