Skip to content

Commit cd1e6f9

Browse files
committed
Merge pull request scala#793 from jsuereth/fix/convert-to
Renaming convertTo to to on GenTraversableOnce.
2 parents bad1e8e + 296d00f commit cd1e6f9

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/library/scala/collection/GenTraversableOnce.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,10 @@ trait GenTraversableOnce[+A] extends Any {
565565
* @tparam Col The collection type to build.
566566
* @return a new collection containing all elements of this $coll.
567567
*
568-
* @usecase def convertTo[Col[_]]: Col[A]
568+
* @usecase def to[Col[_]]: Col[A]
569569
* @inheritdoc
570570
* $willNotTerminateInf
571571
* @return a new collection containing all elements of this $coll.
572572
*/
573-
def convertTo[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV]
573+
def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV]
574574
}

src/library/scala/collection/TraversableLike.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ trait TraversableLike[+A, +Repr] extends Any
617617
def toIterator: Iterator[A] = toStream.iterator
618618
def toStream: Stream[A] = toBuffer.toStream
619619
// Override to provide size hint.
620-
override def convertTo[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV] = {
620+
override def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV] = {
621621
val b = cbf()
622622
b.sizeHint(this)
623623
b ++= thisCollection

src/library/scala/collection/TraversableOnce.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,21 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
240240

241241
def toTraversable: Traversable[A]
242242

243-
def toList: List[A] = convertTo[List]
243+
def toList: List[A] = to[List]
244244

245245
def toIterable: Iterable[A] = toStream
246246

247247
def toSeq: Seq[A] = toStream
248248

249-
def toIndexedSeq: immutable.IndexedSeq[A] = convertTo[immutable.IndexedSeq]
249+
def toIndexedSeq: immutable.IndexedSeq[A] = to[immutable.IndexedSeq]
250250

251-
def toBuffer[B >: A]: mutable.Buffer[B] = convertTo[ArrayBuffer].asInstanceOf[mutable.Buffer[B]]
251+
def toBuffer[B >: A]: mutable.Buffer[B] = to[ArrayBuffer].asInstanceOf[mutable.Buffer[B]]
252252

253-
def toSet[B >: A]: immutable.Set[B] = convertTo[immutable.Set].asInstanceOf[immutable.Set[B]]
253+
def toSet[B >: A]: immutable.Set[B] = to[immutable.Set].asInstanceOf[immutable.Set[B]]
254254

255-
def toVector: Vector[A] = convertTo[Vector]
255+
def toVector: Vector[A] = to[Vector]
256256

257-
def convertTo[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV] = {
257+
def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV] = {
258258
val b = cbf()
259259
b ++= seq
260260
b.result

src/library/scala/collection/parallel/ParIterableLike.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,11 +851,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
851851

852852
override def toMap[K, V](implicit ev: T <:< (K, V)): immutable.ParMap[K, V] = toParMap[K, V, immutable.ParMap[K, V]](() => immutable.ParMap.newCombiner[K, V])
853853

854-
override def toVector: Vector[T] = convertTo[Vector]
854+
override def toVector: Vector[T] = to[Vector]
855855

856-
override def convertTo[Col[_]](implicit cbf: CanBuildFrom[Nothing, T, Col[T @uncheckedVariance]]): Col[T @uncheckedVariance] = if (cbf().isCombiner) {
856+
override def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, T, Col[T @uncheckedVariance]]): Col[T @uncheckedVariance] = if (cbf().isCombiner) {
857857
toParCollection[T, Col[T]](() => cbf().asCombiner)
858-
} else seq.convertTo(cbf)
858+
} else seq.to(cbf)
859859

860860
/* tasks */
861861

test/files/pos/t5953.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package object foo {
1010

1111
package foo {
1212
object Test {
13-
def f1[T](xs: Traversable[T]) = xs.convertTo[immutable.Vector]
13+
def f1[T](xs: Traversable[T]) = xs.to[immutable.Vector]
1414
def f2[T](xs: Traversable[T]) = xs.build[immutable.Vector]
1515
}
1616
}

test/files/presentation/ide-bug-1000531.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ retrieved 126 members
2525
[accessible: true] `method collectFirst[B](pf: PartialFunction[B,B])Option[B]`
2626
[accessible: true] `method collect[B](pf: PartialFunction[B,B])Iterator[B]`
2727
[accessible: true] `method contains(elem: Any)Boolean`
28-
[accessible: true] `method convertTo[Col[_]](implicit cbf: scala.collection.generic.CanBuildFrom[Nothing,B,Col[B]])Col[B]`
2928
[accessible: true] `method copyToArray[B >: B](xs: Array[B])Unit`
3029
[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int)Unit`
3130
[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int, len: Int)Unit`
@@ -111,6 +110,7 @@ retrieved 126 members
111110
[accessible: true] `method toString()String`
112111
[accessible: true] `method toTraversable=> Traversable[B]`
113112
[accessible: true] `method toVector=> Vector[B]`
113+
[accessible: true] `method to[Col[_]](implicit cbf: scala.collection.generic.CanBuildFrom[Nothing,B,Col[B]])Col[B]`
114114
[accessible: true] `method wait()Unit`
115115
[accessible: true] `method wait(x$1: Long)Unit`
116116
[accessible: true] `method wait(x$1: Long, x$2: Int)Unit`

test/files/run/collection-conversions.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ object Test {
3636
val tmp = col
3737
println("-- Testing " + name + " ---")
3838
printResult("[Direct] Vector ", col.toVector, testVector)
39-
printResult("[Copy] Vector ", col.convertTo[Vector], testVector)
39+
printResult("[Copy] Vector ", col.to[Vector], testVector)
4040
printResult("[Direct] Buffer ", col.toBuffer, testBuffer)
41-
printResult("[Copy] Buffer ", col.convertTo[Buffer], testBuffer)
41+
printResult("[Copy] Buffer ", col.to[Buffer], testBuffer)
4242
printResult("[Direct] GenSeq ", col.toSeq, testGenSeq)
43-
printResult("[Copy] GenSeq ", col.convertTo[GenSeq], testGenSeq)
44-
printResult("[Copy] Seq ", col.convertTo[Seq], testSeq)
43+
printResult("[Copy] GenSeq ", col.to[GenSeq], testGenSeq)
44+
printResult("[Copy] Seq ", col.to[Seq], testSeq)
4545
printResult("[Direct] Stream ", col.toStream, testStream)
46-
printResult("[Copy] Stream ", col.convertTo[Stream], testStream)
46+
printResult("[Copy] Stream ", col.to[Stream], testStream)
4747
printResult("[Direct] Array ", col.toArray, testArray)
48-
printResult("[Copy] Array ", col.convertTo[Array], testArray)
49-
printResult("[Copy] ParVector", col.convertTo[ParVector], testParVector)
50-
printResult("[Copy] ParArray ", col.convertTo[ParArray], testParArray)
48+
printResult("[Copy] Array ", col.to[Array], testArray)
49+
printResult("[Copy] ParVector", col.to[ParVector], testParVector)
50+
printResult("[Copy] ParArray ", col.to[ParArray], testParArray)
5151
}
5252

5353
def main(args: Array[String]): Unit = {

0 commit comments

Comments
 (0)