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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-3, 3.0.9, 2.5.16
    • None
    • 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

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            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