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

STC: error for addAll with collect argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.5
    • 4.0.0-alpha-1, 3.0.6, 2.5.16
    • None
    • None

    Description

      Follow up from GROOVY-9734 and GROOVY-8961. New STC error for generics mismatch when pairing collect with a method pointer:

      interface Service {
        Number transform(String s)
      }
      @groovy.transform.TypeChecked
      void test(Service service) {
        Set<Number> numbers = []
        List<String> strings = ['x','y','z']
        numbers.addAll(strings.collect(service.&transform)) // Cannot call java.util.Set <Number>#addAll(java.util.Collection <? extends java.lang.Number>) with arguments [java.util.List <? extends E>]
      }
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            2 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 - 1h
                1h