Skip to content

IndexedSeqView throws ClassCastException on diff, intersect, etc. #8640

@scabug

Description

@scabug
scala> def iv = collection.mutable.IndexedSeq(1,2,3).view
iv: scala.collection.mutable.IndexedSeqView[Int,scala.collection.mutable.IndexedSeq[Int]]

scala> iv diff iv
java.lang.ClassCastException: scala.collection.SeqViewLike$$anon$1 cannot be cast to scala.collection.mutable.IndexedSeqView
  ... 32 elided

scala> iv intersect iv
java.lang.ClassCastException: scala.collection.SeqViewLike$$anon$1 cannot be cast to scala.collection.mutable.IndexedSeqView
  ... 32 elided

Problem is described in more detail in related issues #4190 and #6709. A sensible fix will cover them all. It's mostly SeqView's fault for .asInstanceOf[That]-ing without even checking cbf eq theCbfWeAreExpecting. (Relying on a bunch of manual overrides in IndexedSeqView is not a very good idea either.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions