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

Static compilation fails when using collectMany and elvis operator

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4.7
    • Fix Version/s: None
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      The following code, when used with @CompileStatic, produces Groovyc: [Static type checking] - Cannot call <T,E> java.util.List <Object>#collectMany(groovy.lang.Closure <java.util.Collection>) with arguments [groovy.lang.Closure <java.util.List>]

      List<String> getStrings(List<Object> l) {
          l.collectMany { [it.toString()] } ?: ([] as List<String>)
      }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dvbobrov Dmitry Bobrov
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: