Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10010

STC: method call with GString elements in list/array has different error from assignment

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0-alpha-3
    • Component/s: None
    • Labels:
      None

      Description

      Follow up from GROOVY-5559 and GROOVY-9971. Consider the following:

      void m(List<String> list) { }
      @groovy.transform.TypeChecked
      void test() {
        def bar = 123
        m(["foo","$bar"])
        List<String> strings = ["foo","$bar"]
      }
      

      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>]".

        Attachments

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              emilles Eric Milles

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h

                  Issue deployment