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

Object.with seems to lose typing when generics are used

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0-rc-1
    • Fix Version/s: 2.1.0-rc-2, 2.0.7
    • Component/s: None
    • Labels:
      None

      Description

      The following code:

      @groovy.transform.CompileStatic
      class Test {
        static List<String> a( String s ) {
          s.with { String it -> [ "$it" ] }
        }
      }
      
      assert Test.a( 'tim' ) == [ 'tim' ]
      

      Gives the error:

      [Static type checking] - Cannot return value of type java.lang.Object on method returning type java.util.List <String>
       at line: 4, column: 5
      

        Attachments

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              tim_yates Tim Yates
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: