Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Jun 1, 2014 · 4 comments
Closed

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

scabug opened this issue Jun 1, 2014 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jun 1, 2014

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.)

@scabug
Copy link
Author

scabug commented Jun 1, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8640?orig=1
Reporter: @Ichoran
Affected Versions: 2.11.0
See #4190, #6709

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@som-snytt
Copy link

Still on 2.12. As noted on gitter:

scala> ArrayBuffer(1,2,3,4,5,6,7).view.sliding(2).forall(_.nonEmpty)
java.lang.ClassCastException: scala.collection.SeqViewLike$$anon$1 cannot be cast to scala.collection.mutable.IndexedSeqView

@Ichoran
Copy link

Ichoran commented May 22, 2019

Views are kinda wobbly in 2.12 anyway. If it's still in 2.13, that's a problem.

@dwijnand
Copy link
Member

All ok in 2.13-landia

Welcome to Scala 2.13.0-RC2 (OpenJDK GraalVM CE 19.0.0, Java 1.8.0_212).
Type in expressions for evaluation. Or try :help.

scala> scala.collection.mutable.ArrayBuffer(1,2,3,4,5,6,7).view.sliding(2).forall(_.nonEmpty)
res0: Boolean = true

@SethTisue SethTisue modified the milestones: Backlog, 2.13.0-RC2 May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants