scala / collection-strawman

Implementation of the new Scala 2.13 Collections
Apache License 2.0
200 stars 72 forks source link

mutable.Stack.reverse doesn't return a stack #547

Closed lrytz closed 6 years ago

lrytz commented 6 years ago

2.12:

scala> Stack(1,2,3).reverse
res1: scala.collection.mutable.Stack[Int] = Stack(3, 2, 1)

2.13

scala> Stack(1,2,3).reverse
res12: scala.collection.mutable.ArrayDeque[Int] = ArrayDeque(3, 2, 1)

Can the override in ArrayDeque be implemented to return a C?

Once this is fixed, test/files/run/t4535.scala needs an --update-check.

Side-question: is there a type checking issue? SeqOps.reverse is defined to return C, and we have Stack[A] extends ArrayDeque[A] .. with IndexedSeqOps[A, Stack, Stack[A]] ... It seems to me the override of reverse inherited from ArrayDeque doesn't satisfy the requirement.

Ichoran commented 6 years ago

Note also https://github.com/scala/collection-strawman/issues/505

julienrf commented 6 years ago

I think this is fixed in https://github.com/scala/scala/pull/6508.