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

Views don't interact properly with sequence concatenation #9162

Closed
scabug opened this issue Feb 18, 2015 · 1 comment
Closed

Views don't interact properly with sequence concatenation #9162

scabug opened this issue Feb 18, 2015 · 1 comment

Comments

@scabug
Copy link

scabug commented Feb 18, 2015

As in the title: using concatenation with views can crash Scala during runtime:

scala> Seq(1,2).view ++ Seq(3,4)
res0: scala.collection.SeqView[Int,Seq[_]] = SeqViewA(...)

scala> Seq(1,2).view ++: Seq(3,4)
res1: Seq[Int] = SeqViewA(...)

scala> Seq(1,2).view ++: List(3,4)
java.lang.ClassCastException: scala.collection.SeqViewLike$$anon$2 cannot be cast to scala.collection.immutable.List
  ... 33 elided

scala> Seq(1,2).view ++: Vector(3,4)
java.lang.ClassCastException: scala.collection.SeqViewLike$$anon$2 cannot be cast to scala.collection.immutable.Vector
  ... 33 elided

scala> List(1,2) ++ Seq(1,2).view
res4: List[Int] = List(1, 2, 1, 2)

scala> List(1,2) ++: Seq(1,2).view
java.lang.UnsupportedOperationException: TraversableView.Builder.result
  at scala.collection.TraversableView$NoBuilder.result(TraversableView.scala:27)
  at scala.collection.TraversableView$NoBuilder.result(TraversableView.scala:24)
  at scala.collection.TraversableLike$class.$plus$plus(TraversableLike.scala:159)
  at scala.collection.immutable.List.$plus$plus(List.scala:196)
  at scala.collection.TraversableLike$class.$plus$plus$colon(TraversableLike.scala:236)
  at scala.collection.SeqLike$$anon$2.$plus$plus$colon(SeqLike.scala:646)
  ... 33 elided
@scabug
Copy link
Author

scabug commented Feb 18, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9162?orig=1
Reporter: Aleksander Boruch-Gruszecki (alex.bg)
Affected Versions: 2.11.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants