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

Can assign Collection with super wildcard 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<? super Runnable> foo() {[new Object()]}
      
      @groovy.transform.CompileStatic
      def usage() {
        Runnable[] ar = foo() // here
        ar
      }
      
      println usage()
      

      Expected: compilation should fail
      Actual: compilation completes and execution fails with Cannot cast object 'java.lang.Object@65e98b1c' with class 'java.lang.Object' to class '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: