Skip to content

Behavior changes of intersect operations related to Array.empty[T] between 2.13.5 and 2.13.6 #12403

@LuciferYang

Description

@LuciferYang

reproduction steps

using Scala 2.13.6,

Welcome to Scala 2.13.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_232).
Type in expressions for evaluation. Or try :help.

scala> Array.empty[Double].intersect(Array(0.0))
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [D
  ... 32 elided

scala> Array(0.0).intersect(Array.empty[Double])
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [D
  ... 32 elided

scala> Array.empty[Double].intersect(Array.empty[Double])
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [D
  ... 32 elided

but using Scala 2.13.5

Welcome to Scala 2.13.5 (OpenJDK 64-Bit Server VM, Java 1.8.0_232).
Type in expressions for evaluation. Or try :help.

scala> Array.empty[Double].intersect(Array(0.0))
val res0: Array[Double] = Array()

scala> Array(0.0).intersect(Array.empty[Double])
val res1: Array[Double] = Array()

scala> Array.empty[Double].intersect(Array.empty[Double])
val res2: Array[Double] = Array()

problem

There are behavior changes of intersect operations related to Array.empty[T], return Array() is replaced by throw ClassCastException, Is this expected or a bug?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions