Skip to content

Commit 5c6e542

Browse files
committed
Move sources from tests/pos-special/stdlib to scala2-library-cc
Also reduce diff with the original Scala 2 library sources.
1 parent d0c4817 commit 5c6e542

File tree

151 files changed

+119
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+119
-264
lines changed

compiler/test/dotty/Properties.scala

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ object Properties {
8787

8888
/** If we are using the scala-library TASTy jar */
8989
def usingScalaLibraryTasty: Boolean = scalaLibraryTasty.isDefined
90+
/** If we are using the scala-library TASTy jar */
91+
92+
def usingScalaLibraryCCTasty: Boolean = scalaLibraryTasty.exists(_.contains("scala2-library-cc-tasty"))
9093

9194
/** scala-asm jar */
9295
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")

compiler/test/dotty/tools/dotc/CompilationTests.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class CompilationTests {
4545
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
4646
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
4747
) ::: (
48-
// FIXME: This fails due to a bug involving self types and capture checking
49-
if Properties.usingScalaLibraryTasty then Nil
50-
else List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes))
48+
// TODO create a folder for capture checking tests with the stdlib, or use tests/pos-custom-args/captures under this mode?
49+
if Properties.usingScalaLibraryCCTasty then List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes))
50+
else Nil
5151
)
5252

5353
if scala.util.Properties.isJavaAtLeast("16") then

tests/pos-special/stdlib/collection/ArrayOps.scala renamed to scala2-library-cc/src/scala/collection/ArrayOps.scala

+11-10
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ object ArrayOps {
113113
b.result()
114114
}
115115

116-
def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] =
116+
def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] =
117117
flatMap[B](x => asIterable(f(x)))
118118

119119
/** Creates a new non-strict filter which combines this filter with the given predicate. */
@@ -505,7 +505,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
505505
*
506506
* @return a pair of arrays: the first one made of those values returned by `f` that were wrapped in [[scala.util.Left]],
507507
* and the second one made of those wrapped in [[scala.util.Right]]. */
508-
def partitionMap[A1: ClassTag, A2: ClassTag](f: A => Either[A1, A2]): (Array[A1], Array[A2]) = {
508+
def partitionMap[A1: ClassTag, A2: ClassTag](f: A => Either[A1, A2]): (Array[A1], Array[A2]) = {
509509
val res1 = ArrayBuilder.make[A1]
510510
val res2 = ArrayBuilder.make[A2]
511511
var i = 0
@@ -816,7 +816,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
816816
* }}}
817817
*
818818
*/
819-
def scanLeft[B : ClassTag](z: B)(op: (B, A) => B): Array[B] = {
819+
def scanLeft[ B : ClassTag ](z: B)(op: (B, A) => B): Array[B] = {
820820
var v = z
821821
var i = 0
822822
val res = new Array[B](xs.length + 1)
@@ -855,7 +855,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
855855
* }}}
856856
*
857857
*/
858-
def scanRight[B : ClassTag](z: B)(op: (A, B) => B): Array[B] = {
858+
def scanRight[ B : ClassTag ](z: B)(op: (A, B) => B): Array[B] = {
859859
var v = z
860860
var i = xs.length - 1
861861
val res = new Array[B](xs.length + 1)
@@ -973,7 +973,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
973973
b.result()
974974
}
975975

976-
def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] =
976+
def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] =
977977
flatMap[B](x => asIterable(f(x)))
978978

979979
/** Flattens a two-dimensional array by concatenating all its rows
@@ -1095,7 +1095,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
10951095
* If this array is shorter than `that`, `thisElem` values are used to pad the result.
10961096
* If `that` is shorter than this array, `thatElem` values are used to pad the result.
10971097
*/
1098-
def zipAll[A1 >: A, B](that: Iterable[B], thisElem: A1, thatElem: B): Array[(A1, B)] = {
1098+
def zipAll[A1 >: A, B](that: Iterable[B], thisElem: A1, thatElem: B): Array[(A1, B)] = {
10991099
val b = new ArrayBuilder.ofRef[(A1, B)]()
11001100
val k = that.knownSize
11011101
b.sizeHint(max(k, xs.length))
@@ -1244,7 +1244,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
12441244
* @return a pair of Arrays, containing, respectively, the first and second half
12451245
* of each element pair of this Array.
12461246
*/
1247-
def unzip[A1, A2](implicit asPair: A => (A1, A2), ct1: ClassTag[A1], ct2: ClassTag[A2]): (Array[A1], Array[A2]) = {
1247+
def unzip[A1, A2](implicit asPair: A => (A1, A2), ct1: ClassTag[A1], ct2: ClassTag[A2]): (Array[A1], Array[A2]) = {
12481248
val a1 = new Array[A1](xs.length)
12491249
val a2 = new Array[A2](xs.length)
12501250
var i = 0
@@ -1273,7 +1273,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
12731273
* @return a triple of Arrays, containing, respectively, the first, second, and third
12741274
* elements from each element triple of this Array.
12751275
*/
1276-
def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3), ct1: ClassTag[A1], ct2: ClassTag[A2],
1276+
def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3), ct1: ClassTag[A1], ct2: ClassTag[A2],
12771277
ct3: ClassTag[A3]): (Array[A1], Array[A2], Array[A3]) = {
12781278
val a1 = new Array[A1](xs.length)
12791279
val a2 = new Array[A2](xs.length)
@@ -1418,7 +1418,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
14181418
* @tparam K the type of keys returned by the discriminator function
14191419
* @tparam B the type of values returned by the transformation function
14201420
*/
1421-
def groupMap[K, B : ClassTag](key: A => K)(f: A => B): immutable.Map[K, Array[B]] = {
1421+
def groupMap[K, B : ClassTag](key: A => K)(f: A => B): immutable.Map[K, Array[B]] = {
14221422
val m = mutable.Map.empty[K, ArrayBuilder[B]]
14231423
val len = xs.length
14241424
var i = 0
@@ -1479,7 +1479,8 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal {
14791479
/** Create a copy of this array with the specified element type. */
14801480
def toArray[B >: A: ClassTag]: Array[B] = {
14811481
val destination = new Array[B](xs.length)
1482-
copyToArray(destination, 0)
1482+
@annotation.unused val copied = copyToArray(destination, 0)
1483+
//assert(copied == xs.length)
14831484
destination
14841485
}
14851486

tests/pos-special/stdlib/collection/BuildFrom.scala renamed to scala2-library-cc/src/scala/collection/BuildFrom.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ object BuildFrom extends BuildFromLowPriority1 {
8787
def newBuilder(from: Array[_]): Builder[A, Array[A]] = Factory.arrayFactory[A].newBuilder
8888
}
8989

90-
implicit def buildFromView[A, B]: BuildFrom[View[A], B, View[B]] =
90+
implicit def buildFromView[A, B]: BuildFrom[View[A], B, View[B]] =
9191
new BuildFrom[View[A], B, View[B]] {
9292
def fromSpecific(from: View[A])(it: IterableOnce[B]^): View[B] = View.from(it).unsafeAssumePure
9393
def newBuilder(from: View[A]): Builder[B, View[B]] = View.newBuilder

tests/pos-special/stdlib/collection/IndexedSeq.scala renamed to scala2-library-cc/src/scala/collection/IndexedSeq.scala

+16-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,25 @@ trait IndexedSeqOps[+A, +CC[_], +C] extends Any with IndexedSeqViewOps[A, CC, C]
9494

9595
override def slice(from: Int, until: Int): C = fromSpecific(new IndexedSeqView.Slice(this, from, until))
9696

97-
override def head: A = apply(0)
97+
override def head: A =
98+
if (!isEmpty) apply(0)
99+
else throw new NoSuchElementException(s"head of empty ${
100+
self match {
101+
case self: IndexedSeq[_] => self.collectionClassName
102+
case _ => toString
103+
}
104+
}")
98105

99106
override def headOption: Option[A] = if (isEmpty) None else Some(head)
100107

101-
override def last: A = apply(length - 1)
108+
override def last: A =
109+
if (!isEmpty) apply(length - 1)
110+
else throw new NoSuchElementException(s"last of empty ${
111+
self match {
112+
case self: IndexedSeq[_] => self.collectionClassName
113+
case _ => toString
114+
}
115+
}")
102116

103117
// We already inherit an efficient `lastOption = if (isEmpty) None else Some(last)`
104118

tests/pos-special/stdlib/collection/IterableOnce.scala renamed to scala2-library-cc/src/scala/collection/IterableOnce.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import scala.collection.mutable.StringBuilder
1919
import scala.language.implicitConversions
2020
import scala.math.{Numeric, Ordering}
2121
import scala.reflect.ClassTag
22-
import scala.runtime.AbstractFunction2
22+
import scala.runtime.{AbstractFunction1, AbstractFunction2}
2323
import language.experimental.captureChecking
2424

2525
/**
@@ -272,7 +272,7 @@ object IterableOnce {
272272
math.max(math.min(math.min(len, srcLen), destLen - start), 0)
273273

274274
/** Calls `copyToArray` on the given collection, regardless of whether or not it is an `Iterable`. */
275-
@inline private[collection] def copyElemsToArray[A, B >: A](
275+
@inline private[collection] def copyElemsToArray[A, B >: A](
276276
elems: IterableOnce[A]^,
277277
xs: Array[B],
278278
start: Int = 0,
@@ -1117,8 +1117,8 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A]^ =>
11171117
def collectFirst[B](pf: PartialFunction[A, B]): Option[B] = {
11181118
// Presumably the fastest way to get in and out of a partial function is for a sentinel function to return itself
11191119
// (Tested to be lower-overhead than runWith. Would be better yet to not need to (formally) allocate it)
1120-
val sentinel: scala.Function1[A, Any] = new scala.runtime.AbstractFunction1[A, Any] {
1121-
def apply(a: A) = this
1120+
val sentinel: scala.Function1[A, Any] = new AbstractFunction1[A, Any] {
1121+
def apply(a: A): AbstractFunction1[A, Any] = this
11221122
}
11231123
val it = iterator
11241124
while (it.hasNext) {
@@ -1322,7 +1322,8 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A]^ =>
13221322
def toArray[B >: A: ClassTag]: Array[B] =
13231323
if (knownSize >= 0) {
13241324
val destination = new Array[B](knownSize)
1325-
copyToArray(destination, 0)
1325+
@annotation.unused val copied = copyToArray(destination, 0)
1326+
//assert(copied == destination.length)
13261327
destination
13271328
}
13281329
else mutable.ArrayBuilder.make[B].addAll(this).result()
@@ -1362,4 +1363,4 @@ object IterableOnceOps:
13621363
m
13631364
}
13641365
}
1365-
end IterableOnceOps
1366+
end IterableOnceOps

tests/pos-special/stdlib/collection/MapView.scala renamed to scala2-library-cc/src/scala/collection/MapView.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ object MapView extends MapViewFactory {
161161
override def isEmpty: Boolean = underlying.isEmpty
162162
}
163163

164-
override def newBuilder[X, Y]: Builder[(X, Y), MapView[X, Y]] = mutable.HashMap.newBuilder[X, Y].mapResult(_.view)
164+
override def newBuilder[X, Y]: Builder[(X, Y), MapView[X, Y]] = mutable.HashMap.newBuilder[X, Y].mapResult(_.view)
165165

166166
override def empty[K, V]: MapView[K, V] = EmptyMapView.asInstanceOf[MapView[K, V]]
167167

tests/pos-special/stdlib/collection/SortedSet.scala renamed to scala2-library-cc/src/scala/collection/SortedSet.scala

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]]
6969
* @param start The lower-bound (inclusive) of the iterator
7070
*/
7171
def iteratorFrom(start: A): Iterator[A]
72-
7372
@deprecated("Use `iteratorFrom` instead.", "2.13.0")
7473
@`inline` def keysIteratorFrom(start: A): Iterator[A] = iteratorFrom(start)
7574

tests/pos-special/stdlib/collection/StringParsers.scala renamed to scala2-library-cc/src/scala/collection/StringParsers.scala

-5
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ private[scala] object StringParsers {
167167
else None
168168
}
169169
}
170-
171170
//floating point
172171
final def checkFloatFormat(format: String): Boolean = {
173172
//indices are tracked with a start index which points *at* the first index
@@ -194,7 +193,6 @@ private[scala] object StringParsers {
194193
rec(from)
195194
}
196195

197-
198196
def isHexFloatLiteral(startIndex: Int, endIndex: Int): Boolean = {
199197
def isHexDigit(ch: Char) = ((ch >= '0' && ch <= '9') ||
200198
(ch >= 'a' && ch <= 'f') ||
@@ -232,7 +230,6 @@ private[scala] object StringParsers {
232230
val pIndex = format.indexWhere(ch => ch == 'p' || ch == 'P', startIndex)
233231
(pIndex <= endIndex) && prefixOK(startIndex, pIndex) && postfixOK(pIndex + 1, endIndex)
234232
}
235-
236233
def isDecFloatLiteral(startIndex: Int, endIndex: Int): Boolean = {
237234
//invariant: endIndex > startIndex
238235

@@ -279,7 +276,6 @@ private[scala] object StringParsers {
279276
//count 0x00 to 0x20 as "whitespace", and nothing else
280277
val unspacedStart = format.indexWhere(ch => ch.toInt > 0x20)
281278
val unspacedEnd = format.lastIndexWhere(ch => ch.toInt > 0x20) + 1
282-
283279
if (unspacedStart == -1 || unspacedStart >= unspacedEnd || unspacedEnd <= 0) false
284280
else {
285281
//all formats can have a sign
@@ -306,7 +302,6 @@ private[scala] object StringParsers {
306302
}
307303
}
308304
}
309-
310305
@inline
311306
def parseFloat(from: String): Option[Float] =
312307
if (checkFloatFormat(from)) Some(java.lang.Float.parseFloat(from))

tests/pos-special/stdlib/collection/immutable/ChampCommon.scala renamed to scala2-library-cc/src/scala/collection/immutable/ChampCommon.scala

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ private[immutable] abstract class ChampBaseIterator[T <: Node[T]] {
113113
// ChampBaseReverseIterator and in convert.impl.ChampStepperBase.
114114
// If you change this code, check those also in case they also
115115
// need to be modified.
116-
117116
protected var currentValueCursor: Int = 0
118117
protected var currentValueLength: Int = 0
119118
protected var currentValueNode: T = _

tests/pos-special/stdlib/collection/immutable/TreeSeqMap.scala renamed to scala2-library-cc/src/scala/collection/immutable/TreeSeqMap.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,18 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] {
303303
else EmptyByInsertion
304304
}.asInstanceOf[TreeSeqMap[K, V]]
305305

306-
def from[K, V](it: collection.IterableOnce[(K, V)]^): TreeSeqMap[K, V] =
306+
def from[K, V](it: collection.IterableOnce[(K, V)]^): TreeSeqMap[K, V] =
307307
it match {
308308
case om: TreeSeqMap[K, V] => om
309309
case _ => (newBuilder[K, V] ++= it).result()
310310
}
311311

312312
@inline private def increment(ord: Int) = if (ord == Int.MaxValue) Int.MinValue else ord + 1
313313

314-
def newBuilder[K, V]: mutable.Builder[(K, V), TreeSeqMap[K, V]] = newBuilder(OrderBy.Insertion)
315-
def newBuilder[K, V](orderedBy: OrderBy): mutable.Builder[(K, V), TreeSeqMap[K, V]] = new Builder[K, V](orderedBy)
314+
def newBuilder[K, V]: mutable.Builder[(K, V), TreeSeqMap[K, V]] = newBuilder(OrderBy.Insertion)
315+
def newBuilder[K, V](orderedBy: OrderBy): mutable.Builder[(K, V), TreeSeqMap[K, V]] = new Builder[K, V](orderedBy)
316316

317-
final class Builder[K, V](orderedBy: OrderBy) extends mutable.Builder[(K, V), TreeSeqMap[K, V]] {
317+
final class Builder[K, V](orderedBy: OrderBy) extends mutable.Builder[(K, V), TreeSeqMap[K, V]] {
318318
private[this] val bdr = new MapBuilderImpl[K, (Int, V)]
319319
private[this] var ong = Ordering.empty[K]
320320
private[this] var ord = 0

tests/pos-special/stdlib/collection/mutable/AnyRefMap.scala renamed to scala2-library-cc/src/scala/collection/mutable/AnyRefMap.scala

+17-17
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import language.experimental.captureChecking
4343
* rapidly as 2^30^ is approached.
4444
*
4545
*/
46-
class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, initialBufferSize: Int, initBlank: Boolean)
46+
class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, initialBufferSize: Int, initBlank: Boolean)
4747
extends AbstractMap[K, V]
4848
with MapOps[K, V, Map, AnyRefMap[K, V]]
4949
with StrictOptimizedIterableOps[(K, V), Iterable, AnyRefMap[K, V]]
@@ -478,11 +478,11 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, init
478478
}
479479

480480
// The implicit dummy parameter is necessary to distinguish these methods from the base methods they overload (not override)
481-
def map[K2 <: AnyRef, V2](f: ((K, V)) => (K2, V2))(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] =
481+
def map[K2 <: AnyRef, V2](f: ((K, V)) => (K2, V2))(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] =
482482
AnyRefMap.from(new View.Map(this, f))
483-
def flatMap[K2 <: AnyRef, V2](f: ((K, V)) => IterableOnce[(K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] =
483+
def flatMap[K2 <: AnyRef, V2](f: ((K, V)) => IterableOnce[(K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] =
484484
AnyRefMap.from(new View.FlatMap(this, f))
485-
def collect[K2 <: AnyRef, V2](pf: PartialFunction[(K, V), (K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] =
485+
def collect[K2 <: AnyRef, V2](pf: PartialFunction[(K, V), (K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] =
486486
strictOptimizedCollect(AnyRefMap.newBuilder[K2, V2], pf)
487487

488488
override def clear(): Unit = {
@@ -515,7 +515,7 @@ object AnyRefMap {
515515
*
516516
* This builder can be reused to create multiple instances.
517517
*/
518-
final class AnyRefMapBuilder[K <: AnyRef, V] extends ReusableBuilder[(K, V), AnyRefMap[K, V]] {
518+
final class AnyRefMapBuilder[K <: AnyRef, V] extends ReusableBuilder[(K, V), AnyRefMap[K, V]] {
519519
private[collection] var elems: AnyRefMap[K, V] = new AnyRefMap[K, V]
520520
def addOne(entry: (K, V)): this.type = {
521521
elems += entry
@@ -527,11 +527,11 @@ object AnyRefMap {
527527
}
528528

529529
/** Creates a new `AnyRefMap` with zero or more key/value pairs. */
530-
def apply[K <: AnyRef, V](elems: (K, V)*): AnyRefMap[K, V] = buildFromIterableOnce(elems)
530+
def apply[K <: AnyRef, V](elems: (K, V)*): AnyRefMap[K, V] = buildFromIterableOnce(elems)
531531

532-
def newBuilder[K <: AnyRef, V]: ReusableBuilder[(K, V), AnyRefMap[K, V]] = new AnyRefMapBuilder[K, V]
532+
def newBuilder[K <: AnyRef, V]: ReusableBuilder[(K, V), AnyRefMap[K, V]] = new AnyRefMapBuilder[K, V]
533533

534-
private def buildFromIterableOnce[K <: AnyRef, V](elems: IterableOnce[(K, V)]^): AnyRefMap[K, V] = {
534+
private def buildFromIterableOnce[K <: AnyRef, V](elems: IterableOnce[(K, V)]^): AnyRefMap[K, V] = {
535535
var sz = elems.knownSize
536536
if(sz < 0) sz = 4
537537
val arm = new AnyRefMap[K, V](sz * 2)
@@ -541,10 +541,10 @@ object AnyRefMap {
541541
}
542542

543543
/** Creates a new empty `AnyRefMap`. */
544-
def empty[K <: AnyRef, V]: AnyRefMap[K, V] = new AnyRefMap[K, V]
544+
def empty[K <: AnyRef, V]: AnyRefMap[K, V] = new AnyRefMap[K, V]
545545

546546
/** Creates a new empty `AnyRefMap` with the supplied default */
547-
def withDefault[K <: AnyRef, V](default: K -> V): AnyRefMap[K, V] = new AnyRefMap[K, V](default)
547+
def withDefault[K <: AnyRef, V](default: K -> V): AnyRefMap[K, V] = new AnyRefMap[K, V](default)
548548

549549
/** Creates a new `AnyRefMap` from an existing source collection. A source collection
550550
* which is already an `AnyRefMap` gets cloned.
@@ -554,15 +554,15 @@ object AnyRefMap {
554554
* @tparam V the type of the values
555555
* @return a new `AnyRefMap` with the elements of `source`
556556
*/
557-
def from[K <: AnyRef, V](source: IterableOnce[(K, V)]^): AnyRefMap[K, V] = source match {
557+
def from[K <: AnyRef, V](source: IterableOnce[(K, V)]^): AnyRefMap[K, V] = source match {
558558
case source: AnyRefMap[_, _] => source.clone().asInstanceOf[AnyRefMap[K, V]]
559559
case _ => buildFromIterableOnce(source)
560560
}
561561

562562
/** Creates a new `AnyRefMap` from arrays of keys and values.
563563
* Equivalent to but more efficient than `AnyRefMap((keys zip values): _*)`.
564564
*/
565-
def fromZip[K <: AnyRef, V](keys: Array[K], values: Array[V]): AnyRefMap[K, V] = {
565+
def fromZip[K <: AnyRef, V](keys: Array[K], values: Array[V]): AnyRefMap[K, V] = {
566566
val sz = math.min(keys.length, values.length)
567567
val arm = new AnyRefMap[K, V](sz * 2)
568568
var i = 0
@@ -574,7 +574,7 @@ object AnyRefMap {
574574
/** Creates a new `AnyRefMap` from keys and values.
575575
* Equivalent to but more efficient than `AnyRefMap((keys zip values): _*)`.
576576
*/
577-
def fromZip[K <: AnyRef, V](keys: Iterable[K]^, values: Iterable[V]^): AnyRefMap[K, V] = {
577+
def fromZip[K <: AnyRef, V](keys: Iterable[K]^, values: Iterable[V]^): AnyRefMap[K, V] = {
578578
val sz = math.min(keys.size, values.size)
579579
val arm = new AnyRefMap[K, V](sz * 2)
580580
val ki = keys.iterator
@@ -584,20 +584,20 @@ object AnyRefMap {
584584
arm
585585
}
586586

587-
implicit def toFactory[K <: AnyRef, V](dummy: AnyRefMap.type): Factory[(K, V), AnyRefMap[K, V]] = ToFactory.asInstanceOf[Factory[(K, V), AnyRefMap[K, V]]]
587+
implicit def toFactory[K <: AnyRef, V](dummy: AnyRefMap.type): Factory[(K, V), AnyRefMap[K, V]] = ToFactory.asInstanceOf[Factory[(K, V), AnyRefMap[K, V]]]
588588

589589
@SerialVersionUID(3L)
590590
private[this] object ToFactory extends Factory[(AnyRef, AnyRef), AnyRefMap[AnyRef, AnyRef]] with Serializable {
591591
def fromSpecific(it: IterableOnce[(AnyRef, AnyRef)]^): AnyRefMap[AnyRef, AnyRef] = AnyRefMap.from[AnyRef, AnyRef](it)
592592
def newBuilder: Builder[(AnyRef, AnyRef), AnyRefMap[AnyRef, AnyRef]] = AnyRefMap.newBuilder[AnyRef, AnyRef]
593593
}
594594

595-
implicit def toBuildFrom[K <: AnyRef, V](factory: AnyRefMap.type): BuildFrom[Any, (K, V), AnyRefMap[K, V]] = ToBuildFrom.asInstanceOf[BuildFrom[Any, (K, V), AnyRefMap[K, V]]]
595+
implicit def toBuildFrom[K <: AnyRef, V](factory: AnyRefMap.type): BuildFrom[Any, (K, V), AnyRefMap[K, V]] = ToBuildFrom.asInstanceOf[BuildFrom[Any, (K, V), AnyRefMap[K, V]]]
596596
private[this] object ToBuildFrom extends BuildFrom[Any, (AnyRef, AnyRef), AnyRefMap[AnyRef, AnyRef]] {
597597
def fromSpecific(from: Any)(it: IterableOnce[(AnyRef, AnyRef)]^) = AnyRefMap.from(it)
598598
def newBuilder(from: Any) = AnyRefMap.newBuilder[AnyRef, AnyRef]
599599
}
600600

601-
implicit def iterableFactory[K <: AnyRef, V]: Factory[(K, V), AnyRefMap[K, V]] = toFactory[K, V](this)
602-
implicit def buildFromAnyRefMap[K <: AnyRef, V]: BuildFrom[AnyRefMap[_, _], (K, V), AnyRefMap[K, V]] = toBuildFrom(this)
601+
implicit def iterableFactory[K <: AnyRef, V]: Factory[(K, V), AnyRefMap[K, V]] = toFactory[K, V](this)
602+
implicit def buildFromAnyRefMap[K <: AnyRef, V]: BuildFrom[AnyRefMap[_, _], (K, V), AnyRefMap[K, V]] = toBuildFrom(this)
603603
}

0 commit comments

Comments
 (0)