[
https://issues.apache.org/jira/browse/GROOVY-9224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16978765#comment-16978765
]
Eric Milles commented on GROOVY-9224:
-------------------------------------
Looks like static type checking is performed within
{{org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor#processNamedParam}}.
This was added as part of GROOVY-7632.
> 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)