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

Object.with seems to lose typing when generics are used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0-rc-1
    • 2.1.0-rc-2, 2.0.7
    • None
    • 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

            melix Cédric Champeau
            tim_yates Tim Yates
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: