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 2021/04/05 16:45:00 UTC

[jira] [Updated] (GROOVY-10010) STC: method call with GString elements in list/array has different error from assignment

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

Eric Milles updated GROOVY-10010:
---------------------------------
    Summary: STC: method call with GString elements in list/array has different error from assignment  (was: STC: ...)

> STC: method call with GString elements in list/array has different error from assignment
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10010
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10010
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>
> Follow up from GROOVY-5559 and GROOVY-9971.  Consider the following:
> {code:groovy}
> void m(List<String> list) { }
> @groovy.transform.TypeChecked
> void test() {
>   def bar = 123
>   m(["foo","$bar"])
>   List<String> strings = ["foo","$bar"]
> }
> {code}
> The assignment yields a nice error message as per 5559: "You are trying to use a GString in place of a String in a type which explicitly declares accepting String. Make sure to call toString() on all GString values."
> The direct use of a list expression as a call argument still retains the less-informative generics compatibility error: "Cannot call Script#m(java.util.List <java.lang.String>) with arguments [java.util.ArrayList <java.io.Serializable>]".



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