Scala Programming Language
  1. Scala Programming Language
  2. SI-5353

Type inference fail with Array produces ClassCastException at runtime

    Details

      Description

      scala> if (false) Array("qwe") else Array()
      java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
      

      Expected: either compilation error, or correct inference for the second array creation

        Issue Links

          Activity

          Hide
          Adriaan Moors added a comment -

          Array[T] where T <: Nothing or T <: Null must be ruled out

          Show
          Adriaan Moors added a comment - Array [T] where T <: Nothing or T <: Null must be ruled out
          Hide
          Paul Phillips added a comment -

          Adriaan, where do you think it should happen? I have found it difficult.

          Show
          Paul Phillips added a comment - Adriaan, where do you think it should happen? I have found it difficult.
          Hide
          Jason Zaugg added a comment -

          How about cutting if off in the inputs to lub, and then more generally in a tree traversal in refchecks?

          Show
          Jason Zaugg added a comment - How about cutting if off in the inputs to lub, and then more generally in a tree traversal in refchecks?
          Hide
          Paul Phillips added a comment -
          Show
          Paul Phillips added a comment - I stopped at the comma; https://github.com/scala/scala/pull/2486
          Hide
          James Iry added a comment -

          2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

          Show
          James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

            People

            • Assignee:
              Unassigned
              Reporter:
              Oleg Aleshko
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:

                Development