Skip to content

Commit dde2c0f

Browse files
authored
Merge pull request scala#6539 from Jasper-M/topic/cleanup-strawman
Clean up unnecessary strawman conversions
2 parents 2686334 + 567a8dc commit dde2c0f

File tree

10 files changed

+8
-66
lines changed

10 files changed

+8
-66
lines changed

src/library/scala/collection/immutable/NumericRange.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.collection.immutable
22

3-
import scala.collection.{SeqFactory, IterableFactory, IterableOnce, Iterator, StrictOptimizedIterableOps, arrayToArrayOps}
3+
import scala.collection.{SeqFactory, IterableFactory, IterableOnce, Iterator, StrictOptimizedIterableOps}
44

55
import java.lang.String
66

@@ -197,7 +197,7 @@ sealed class NumericRange[T](
197197
override def containsTyped(el: A) = underlyingRange exists (x => fm(x) == el)
198198

199199
override def toString = {
200-
def simpleOf(x: Any): String = collection.arrayToArrayOps(x.getClass.getName.split("\\.")).last
200+
def simpleOf(x: Any): String = x.getClass.getName.split("\\.").last
201201
val stepped = simpleOf(underlyingRange.step)
202202
s"${super.toString} (using $underlyingRange of $stepped)"
203203
}

src/library/scala/collection/immutable/TrieIterator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e
184184
depth -= 1
185185
1 until arrayStack.length foreach (i => arrayStack(i - 1) = arrayStack(i))
186186
arrayStack(arrayStack.length - 1) = Array[Iterable[T]](null)
187-
posStack = scala.collection.arrayToArrayOps(scala.collection.arrayToArrayOps(posStack).tail) ++ Array[Int](0)
187+
posStack = posStack.tail ++ Array[Int](0)
188188
// we know that `this` is not empty, since it had something on the arrayStack and arrayStack elements are always non-empty
189189
((newIterator(snd), szsnd), this)
190190
} else {

src/library/scala/collection/mutable/FlatHashTable.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package collection.mutable
33

44
import collection.Iterator
55

6-
import collection.arrayToWrappedArray
7-
86
import java.lang.{Integer, ThreadLocal}
97

108
import java.lang.Integer.rotateRight

src/library/scala/collection/mutable/HashTable.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ package scala
1010
package collection.mutable
1111

1212
import collection.Iterator
13-
import collection.arrayToWrappedArray
1413

1514
import java.lang.Integer.{numberOfLeadingZeros, rotateRight}
1615
import scala.util.hashing.byteswap32

src/library/scala/collection/mutable/Queue.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ package scala.collection
1010
package mutable
1111

1212

13-
import scala.collection.toNewSeq
14-
1513
/** `Queue` objects implement data structures that allow to
1614
* insert and retrieve elements in a first-in-first-out (FIFO) manner.
1715
*

src/library/scala/collection/mutable/Seq.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.collection.mutable
22

3-
import scala.collection.{IterableOnce, SeqFactory, toNewSeq, toOldSeq}
3+
import scala.collection.{IterableOnce, SeqFactory}
44
import scala.language.higherKinds
55

66
trait Seq[A]

src/library/scala/collection/mutable/Shrinkable.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package collection.mutable
33

44
import scala.annotation.tailrec
55

6-
import collection.toNewSeq
7-
86
/** This trait forms part of collections that can be reduced
97
* using a `-=` operator.
108
*

src/library/scala/collection/mutable/Stack.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scala.collection.mutable
22

33
import scala.annotation.migration
4-
import scala.collection.{IterableOnce, SeqFactory, StrictOptimizedSeqFactory, StrictOptimizedSeqOps, toNewSeq}
4+
import scala.collection.{IterableOnce, SeqFactory, StrictOptimizedSeqFactory, StrictOptimizedSeqOps}
55

66
/** A stack implements a data structure which allows to store and retrieve
77
* objects in a last-in-first-out (LIFO) fashion.

src/library/scala/collection/package.scala

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package scala
22

33
import scala.language.higherKinds
44

5-
package object collection extends LowPriority {
5+
package object collection {
66
@deprecated("Use Iterable instead of Traversable", "2.13.0")
77
type Traversable[+X] = Iterable[X]
88
@deprecated("Use Iterable instead of Traversable", "2.13.0")
@@ -41,39 +41,6 @@ package object collection extends LowPriority {
4141
@deprecated("Gen* collection types have been removed", "2.13.0")
4242
val GenMap = Map
4343

44-
import scala.language.implicitConversions
45-
// ------------------ Decorators to add collection ops to existing types -----------------------
46-
47-
/** Decorator to add collection operations to strings. */
48-
def stringToStringOps(s: String): StringOps = new StringOps(s)
49-
50-
/** Decorator to add collection operations to arrays. */
51-
def arrayToArrayOps[A](as: Array[A]): ArrayOps[A] = new ArrayOps[A](as)
52-
53-
class toNewIterator[A](val it: scala.Iterator[A]) extends AnyVal {
54-
def toStrawman = new scala.collection.Iterator[A] {
55-
def hasNext = it.hasNext
56-
def next() = it.next()
57-
}
58-
}
59-
60-
class toOldIterator[A](val it: scala.collection.Iterator[A]) extends AnyVal {
61-
def toClassic = new scala.Iterator[A] {
62-
def hasNext = it.hasNext
63-
def next() = it.next()
64-
}
65-
}
66-
67-
class toNewSeq[A](val s: scala.collection.Seq[A]) extends AnyVal {
68-
def toStrawman: scala.collection.Seq[A] =
69-
new scala.collection.mutable.ArrayBuffer() ++= s.iterator
70-
}
71-
72-
class toOldSeq[A](val s: scala.collection.Seq[A]) extends AnyVal {
73-
def toClassic: scala.collection.Seq[A] =
74-
new scala.collection.mutable.ArrayBuffer ++= s.iterator()
75-
}
76-
7744
/** Needed to circumvent a difficulty between dotty and scalac concerning
7845
* the right top type for a type parameter of kind * -> *.
7946
* In Scalac, we can provide `Any`, as `Any` is kind-polymorphic. In dotty this is not allowed.
@@ -107,13 +74,6 @@ package object collection extends LowPriority {
10774
}
10875
}
10976

110-
def optionToIterableOnce[A](maybeA: scala.Option[A]): IterableOnce[A] =
111-
new Iterator[A] {
112-
private var _hasNext = maybeA.nonEmpty
113-
def next(): A = if (_hasNext) { _hasNext = false; maybeA.get } else Iterator.empty.next()
114-
def hasNext: Boolean = _hasNext
115-
}
116-
11777
/** An extractor used to head/tail deconstruct sequences. */
11878
object +: {
11979
/** Splits a sequence into head :+ tail.
@@ -134,14 +94,3 @@ package object collection extends LowPriority {
13494
else Some(t.init -> t.last)
13595
}
13696
}
137-
138-
class LowPriority {
139-
import scala.language.implicitConversions
140-
import scala.collection._
141-
142-
/** Convert array to WrappedArray. Lower priority than ArrayOps */
143-
def arrayToWrappedArray[T](xs: Array[T]): mutable.IndexedSeq[T] = mutable.WrappedArray.make(xs)
144-
145-
/** Convert String to Seq. Lower priority than StringOps */
146-
def stringToSeq(s: String): immutable.WrappedString = new immutable.WrappedString(s)
147-
}

test/files/pos/virtpatmat_gadt_array.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ object Test {
1111
// (OptionMatching.guard(null.==(x1), x1.asInstanceOf[Array[T]]).flatMap(((x3: Array[T]) =>
1212
// OptionMatching.one(null))): Option[scala.collection.mutable.ArrayOps[T]])): Option[scala.collection.mutable.ArrayOps[T]]).orElse((OptionMatching.zero: Option[scala.collection.mutable.ArrayOps[T]]))))
1313

14-
def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = collection.arrayToArrayOps(xs)
15-
}
14+
def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps(xs)
15+
}

0 commit comments

Comments
 (0)