Skip to content

Commit

Permalink
Merge pull request #581 from RustedBones/typed-can-build-from
Browse files Browse the repository at this point in the history
Make ArraySeq extends IndexedSeqOptimized
  • Loading branch information
lrytz committed Apr 12, 2023
2 parents 4fbfad2 + 9d64f5c commit cd00be9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package scala.collection.compat.immutable
import java.util.Arrays

import scala.annotation.unchecked.uncheckedVariance
import scala.collection.AbstractSeq
import scala.collection.{AbstractSeq, IndexedSeqOptimized}
import scala.collection.generic._
import scala.collection.immutable.IndexedSeq
import scala.collection.mutable.{ArrayBuilder, Builder, WrappedArrayBuilder}
Expand All @@ -34,7 +34,10 @@ import scala.util.hashing.MurmurHash3
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
abstract class ArraySeq[+T] extends AbstractSeq[T] with IndexedSeq[T] {
abstract class ArraySeq[+T]
extends AbstractSeq[T]
with IndexedSeq[T]
with IndexedSeqOptimized[T, ArraySeq[T]] {

override protected[this] def thisCollection: ArraySeq[T] = this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,11 @@ class ArraySeqTest {
Assert.assertEquals(ArraySeq[T](), array.slice(1, 1))
Assert.assertEquals(ArraySeq[T](), array.slice(2, 1))
}

@Test def ArraySeqIndexedSeqOptimized(): Unit = {
val x = ArraySeq(1, 2)
val y = ArraySeq(3, 4)
val z: ArraySeq[Int] = x ++ y
assert(z.toList == List(1, 2, 3, 4))
}
}

0 comments on commit cd00be9

Please sign in to comment.