diff options
-rw-r--r-- | src/library/scala/collection/generic/SequenceViewTemplate.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/generic/VectorViewTemplate.scala | 5 | ||||
-rw-r--r-- | test/files/run/t2074.scala | 3 | ||||
-rw-r--r-- | test/files/run/t2074_2.check | 1 | ||||
-rw-r--r-- | test/files/run/t2074_2.scala | 15 |
5 files changed, 25 insertions, 1 deletions
diff --git a/src/library/scala/collection/generic/SequenceViewTemplate.scala b/src/library/scala/collection/generic/SequenceViewTemplate.scala index cd67b81d26..4fb918628d 100644 --- a/src/library/scala/collection/generic/SequenceViewTemplate.scala +++ b/src/library/scala/collection/generic/SequenceViewTemplate.scala @@ -112,7 +112,7 @@ trait SequenceViewTemplate[+A, protected[this] val from: Int protected[this] val patch: Sequence[B] protected[this] val replaced: Int - private val plen = patch.length + private lazy val plen = patch.length override def iterator: Iterator[B] = self.iterator patch (from, patch.iterator, replaced) override def length: Int = self.length + plen - replaced override def apply(idx: Int): B = diff --git a/src/library/scala/collection/generic/VectorViewTemplate.scala b/src/library/scala/collection/generic/VectorViewTemplate.scala index f25c4a949e..a8dcc05180 100644 --- a/src/library/scala/collection/generic/VectorViewTemplate.scala +++ b/src/library/scala/collection/generic/VectorViewTemplate.scala @@ -64,6 +64,8 @@ trait VectorViewTemplate[+A, override def foreach[U](f: B => U) = super[Transformed].foreach(f) } + trait Zipped[B] extends Transformed[(A, B)] with super.Zipped[B] + /** Boilerplate method, to override in each subclass * This method could be eliminated if Scala had virtual classes */ @@ -78,4 +80,7 @@ trait VectorViewTemplate[+A, protected override def newPatched[B >: A](_from: Int, _patch: Sequence[B], _replaced: Int): Transformed[B] = new Patched[B] { val from = _from; val patch = _patch; val replaced = _replaced } + protected override def newZipped[B](that: Sequence[B]): Transformed[(A, B)] = new Zipped[B] { + val other = that + } } diff --git a/test/files/run/t2074.scala b/test/files/run/t2074.scala new file mode 100644 index 0000000000..60646be733 --- /dev/null +++ b/test/files/run/t2074.scala @@ -0,0 +1,3 @@ +object Test extends Application { + List.range(1,11).view.patch(5, List(100,101), 2) +} diff --git a/test/files/run/t2074_2.check b/test/files/run/t2074_2.check new file mode 100644 index 0000000000..6bb1d596bd --- /dev/null +++ b/test/files/run/t2074_2.check @@ -0,0 +1 @@ +VectorViewTemplateZ((1,1), (2,2), (3,3)) diff --git a/test/files/run/t2074_2.scala b/test/files/run/t2074_2.scala new file mode 100644 index 0000000000..6aca6c3f60 --- /dev/null +++ b/test/files/run/t2074_2.scala @@ -0,0 +1,15 @@ +import scala.collection.immutable.Vector +import scala.collection.generic.VectorView + +object Test { + val v = new VectorView[Int, Vector[Int]] { + def underlying = Vector(1,2,3) + def apply(idx: Int) = underlying(idx) + def length = underlying.length + } + + def main(args: Array[String]): Unit = { + println(go) + } + def go = v zip v +} |