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

Cannot assign Collection to Array

    XMLWordPrintableJSON

    Details

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

      Description

      Collection<? extends Runnable> foo() {}
      
      @groovy.transform.CompileStatic
      def usage() {
        Runnable[] ar = foo() // OK as expected
      }
      
      @groovy.transform.CompileStatic
      def usage(Collection<? extends Runnable> cr) {
        Runnable[] ar = cr // [Static type checking] - Cannot assign value of type java.util.Collection <? extends java.lang.Runnable> to variable of type java.lang.Runnable[]
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                daniilo Daniil Ovchinnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: