diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/colltest6/CollectionStrawMan6_1.scala | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/tests/run/colltest6/CollectionStrawMan6_1.scala b/tests/run/colltest6/CollectionStrawMan6_1.scala index b5776433e..1cd841336 100644 --- a/tests/run/colltest6/CollectionStrawMan6_1.scala +++ b/tests/run/colltest6/CollectionStrawMan6_1.scala @@ -138,7 +138,7 @@ object CollectionStrawMan6 extends LowPriority { } /** Base trait for linearly accessed sequences */ - trait LinearSeq[+A] extends Seq[A] { self => + trait LinearSeq[+A] extends Seq[A] with SeqLike[A, LinearSeq] { self => def iterator = new Iterator[A] { private[this] var current: Seq[A] = self @@ -154,15 +154,8 @@ object CollectionStrawMan6 extends LowPriority { def length: Int = if (isEmpty) 0 else 1 + tail.length /** Optimized version of `drop` that avoids copying */ - final override def drop(n: Int) = { - var current: Seq[A] = this - var i = n - while (i > 0) { - current = current.tail - i -= 1 - } - current - } + @tailrec final override def drop(n: Int) = + if (n <= 0) this else tail.drop(n - 1) } /** Base trait for strict collections that can be built using a builder. |