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 2019/11/22 16:56:00 UTC

[jira] [Resolved] (GROOVY-9224) Compiler can't convert int to String for @NamedParams[]

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

Eric Milles resolved GROOVY-9224.
---------------------------------
    Resolution: Not A Problem

> Compiler can't convert int to String for @NamedParams[]
> -------------------------------------------------------
>
>                 Key: GROOVY-9224
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9224
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.6
>            Reporter: Ekaterina Alekseeva
>            Priority: Major
>
> Try to compile following code with groovy-2.5.6:
> {code:java}
> @CompileStatic
>  void namedParams(@NamedParams([
>         @NamedParam(value = 'last', type = String)
>  ]) Map args, int i) {
>     print args.last
>  }
> @CompileStatic
>  def m() {
>     namedParams(1, last: 1)// 1 (int) should be converted to String
>  }
> {code}
>  
> There will be an error: {color:#e01e5a}Error:(16, 17) Groovyc: [Static type checking] - parameter for named arg 'last' has type 'int' but expected 'java.lang.String'{color}
>  
> It works fine in groovy 2.5.4 or if there's only one @NamedParam, like in this example:
> @CompileStatic
> void namedParam(@NamedParam(value = 'last', type = String) Map args, int i) {
>     print args.last
> }
> @CompileStatic
> def m() {
>     namedParam(1, last: 1) // 1 (int) successfully converted to String
> }



--
This message was sent by Atlassian Jira
(v8.3.4#803005)