From 97bd54ecf38bd8c4a29e2aee655fdbf7c29b0dcd Mon Sep 17 00:00:00 2001 From: Aleksandar Pokopec Date: Wed, 16 Jun 2010 16:40:02 +0000 Subject: Fixes #3563. Review by extempore. --- src/library/scala/collection/IterableLike.scala | 7 +++++++ src/library/scala/collection/TraversableOnce.scala | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index 5ae4677f4e..538fd09c0e 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -353,6 +353,13 @@ self => override /*TraversableLike*/ def toStream: Stream[A] = iterator.toStream + /** Converts this $coll to a sequence. + * + * $willNotTerminateInf + * @return a sequence containing all the elements of this $coll. + */ + override /*TraversableOnce*/ def toSeq: Seq[A] = toList + /** Method called from equality methods, so that user-defined subclasses can * refuse to be equal to other collections of the same kind. * @param that The object with which this $coll should be compared diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 6bedf025d4..de4eb6fc22 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -399,15 +399,19 @@ trait TraversableOnce[+A] { def toList: List[A] = new ListBuffer[A] ++= self toList /** Converts this $coll to an iterable collection. Note that - * the choice of target Iterable must be lazy as this TraversableOnce - * may be lazy and unevaluated. + * the choice of target `Iterable` is lazy in this default implementation + * as this `TraversableOnce` may be lazy and unevaluated (i.e. it may + * be an iterator which is only traversable once). * * $willNotTerminateInf * @return an `Iterable` containing all elements of this $coll. */ def toIterable: Iterable[A] = toStream - /** Converts this $coll to a sequence. As with toIterable, it must be lazy. + /** Converts this $coll to a sequence. As with `toIterable`, it's lazy + * in this default implementation, as this `TraversableOnce` may be + * lazy and unevaluated. + * * $willNotTerminateInf * @return a sequence containing all elements of this $coll. */ -- cgit v1.2.3