Skip to content

Commit ec070b7

Browse files
committed
Rename WrappedArray to ArraySeq
1 parent f58c9a8 commit ec070b7

24 files changed

+153
-164
lines changed

spec/12-the-scala-standard-library.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ operations on an array `xs`:
427427

428428
Two implicit conversions exist in `Predef` that are frequently applied to arrays:
429429
a conversion to `scala.collection.mutable.ArrayOps` and a conversion to
430-
`scala.collection.mutable.WrappedArray` (a subtype of `scala.collection.Seq`).
430+
`scala.collection.mutable.ArraySeq` (a subtype of `scala.collection.Seq`).
431431

432432
Both types make many of the standard operations found in the Scala
433433
collections API available. The conversion to `ArrayOps` is temporary, as all operations
434-
defined on `ArrayOps` return a value of type `Array`, while the conversion to `WrappedArray`
435-
is permanent as all operations return a value of type `WrappedArray`.
436-
The conversion to `ArrayOps` takes priority over the conversion to `WrappedArray`.
434+
defined on `ArrayOps` return a value of type `Array`, while the conversion to `ArraySeq`
435+
is permanent as all operations return a value of type `ArraySeq`.
436+
The conversion to `ArrayOps` takes priority over the conversion to `ArraySeq`.
437437

438438
Because of the tension between parametrized types in Scala and the ad-hoc
439439
implementation of arrays in the host-languages, some subtle points
@@ -739,9 +739,9 @@ The available low-priority implicits include definitions falling into the follow
739739
can be implicitly converted to instances of class `runtime.RichInt`.
740740

741741
1. For every array type with elements of primitive type, a wrapper that
742-
takes the arrays of that type to instances of a `runtime.WrappedArray` class. For instance, values of type `Array[Float]` can be implicitly converted to instances of class `runtime.WrappedArray[Float]`.
742+
takes the arrays of that type to instances of a `ArraySeq` class. For instance, values of type `Array[Float]` can be implicitly converted to instances of class `ArraySeq[Float]`.
743743
There are also generic array wrappers that take elements
744-
of type `Array[T]` for arbitrary `T` to `WrappedArray`s.
744+
of type `Array[T]` for arbitrary `T` to `ArraySeq`s.
745745

746746
1. An implicit conversion from `String` to `WrappedString`.
747747

src/compiler/scala/tools/nsc/ast/TreeGen.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
122122
def mkForwarder(target: Tree, vparamss: List[List[Symbol]]) =
123123
(target /: vparamss)((fn, vparams) => Apply(fn, vparams map paramToArg))
124124

125-
/** Applies a wrapArray call to an array, making it a WrappedArray or ArraySeq suitable for Scala varargs.
126-
* Don't let a reference type parameter be inferred, in case it's a singleton:
127-
* apply the element type directly.
125+
/** Applies a wrapArray call to an array, making it a mutable (old collections) or immutable
126+
* (new collections) ArraySeq suitable for Scala varargs. Don't let a reference type parameter be
127+
* inferred, in case it's a singleton: apply the element type directly.
128128
*/
129129
def mkWrapVarargsArray(tree: Tree, elemtp: Type) = {
130130
mkMethodCall(

src/library/scala/Array.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ object Array {
498498
// !!! the null check should to be necessary, but without it 2241 fails. Seems to be a bug
499499
// in pattern matcher. @PP: I noted in #4364 I think the behavior is correct.
500500
// Is ArraySeq safe here? In 2.12 we used to call .toIndexedSeq which copied the array
501-
// instead of wrapping it in a WrappedArray but it appears unnecessary.
501+
// instead of wrapping it in a ArraySeq but it appears unnecessary.
502502
}
503503

504504
/** Arrays are mutable, indexed collections of values. `Array[T]` is Scala's representation
@@ -518,12 +518,12 @@ object Array {
518518
*
519519
* Two implicit conversions exist in [[scala.Predef]] that are frequently applied to arrays: a conversion
520520
* to [[scala.collection.mutable.ArrayOps]] (shown on line 4 of the example above) and a conversion
521-
* to [[scala.collection.mutable.WrappedArray]] (a subtype of [[scala.collection.Seq]]).
521+
* to [[scala.collection.mutable.ArraySeq]] (a subtype of [[scala.collection.Seq]]).
522522
* Both types make available many of the standard operations found in the Scala collections API.
523523
* The conversion to `ArrayOps` is temporary, as all operations defined on `ArrayOps` return an `Array`,
524-
* while the conversion to `WrappedArray` is permanent as all operations return a `WrappedArray`.
524+
* while the conversion to `ArraySeq` is permanent as all operations return a `ArraySeq`.
525525
*
526-
* The conversion to `ArrayOps` takes priority over the conversion to `WrappedArray`. For instance,
526+
* The conversion to `ArrayOps` takes priority over the conversion to `ArraySeq`. For instance,
527527
* consider the following code:
528528
*
529529
* {{{
@@ -534,8 +534,8 @@ object Array {
534534
*
535535
* Value `arrReversed` will be of type `Array[Int]`, with an implicit conversion to `ArrayOps` occurring
536536
* to perform the `reverse` operation. The value of `seqReversed`, on the other hand, will be computed
537-
* by converting to `WrappedArray` first and invoking the variant of `reverse` that returns another
538-
* `WrappedArray`.
537+
* by converting to `ArraySeq` first and invoking the variant of `reverse` that returns another
538+
* `ArraySeq`.
539539
*
540540
* @author Martin Odersky
541541
* @version 1.0

src/library/scala/Predef.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ import scala.annotation.elidable.ASSERTION
103103
* @groupprio conversions-anyval-to-java 100
104104
* @groupdesc conversions-anyval-to-java Implicit conversion from Scala AnyVals to Java primitive wrapper types equivalents.
105105
*
106-
* @groupname conversions-array-to-wrapped-array Array to WrappedArray
106+
* @groupname conversions-array-to-wrapped-array Array to ArraySeq
107107
* @groupprio conversions-array-to-wrapped-array 110
108-
* @groupdesc conversions-array-to-wrapped-array Conversions from Arrays to WrappedArrays.
108+
* @groupdesc conversions-array-to-wrapped-array Conversions from Arrays to ArraySeqs.
109109
*/
110110
object Predef extends LowPriorityImplicits {
111111
/**
@@ -745,7 +745,7 @@ object Predef extends LowPriorityImplicits {
745745
// cyclic reference errors compiling the standard library *without* a previously
746746
// compiled copy on the classpath.
747747
private[scala] abstract class LowPriorityImplicits extends LowPriorityImplicits2 {
748-
import mutable.WrappedArray
748+
import mutable.ArraySeq
749749
//import immutable.WrappedString
750750

751751
/** We prefer the java.lang.* boxed types to these wrappers in
@@ -768,38 +768,38 @@ private[scala] abstract class LowPriorityImplicits extends LowPriorityImplicits2
768768
@inline implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
769769

770770
/** @group conversions-array-to-wrapped-array */
771-
implicit def genericWrapArray[T](xs: Array[T]): WrappedArray[T] =
771+
implicit def genericWrapArray[T](xs: Array[T]): ArraySeq[T] =
772772
if (xs eq null) null
773-
else WrappedArray.make(xs)
773+
else ArraySeq.make(xs)
774774

775775
// Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef]
776776
// is as good as another for all T <: AnyRef. Instead of creating 100,000,000
777777
// unique ones by way of this implicit, let's share one.
778778
/** @group conversions-array-to-wrapped-array */
779-
implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): WrappedArray.ofRef[T] = {
779+
implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): ArraySeq.ofRef[T] = {
780780
if (xs eq null) null
781-
else if (xs.length == 0) WrappedArray.empty[AnyRef].asInstanceOf[WrappedArray.ofRef[T]]
782-
else new WrappedArray.ofRef[T](xs)
781+
else if (xs.length == 0) ArraySeq.empty[AnyRef].asInstanceOf[ArraySeq.ofRef[T]]
782+
else new ArraySeq.ofRef[T](xs)
783783
}
784784

785785
/** @group conversions-array-to-wrapped-array */
786-
implicit def wrapIntArray(xs: Array[Int]): WrappedArray.ofInt = if (xs ne null) new WrappedArray.ofInt(xs) else null
786+
implicit def wrapIntArray(xs: Array[Int]): ArraySeq.ofInt = if (xs ne null) new ArraySeq.ofInt(xs) else null
787787
/** @group conversions-array-to-wrapped-array */
788-
implicit def wrapDoubleArray(xs: Array[Double]): WrappedArray.ofDouble = if (xs ne null) new WrappedArray.ofDouble(xs) else null
788+
implicit def wrapDoubleArray(xs: Array[Double]): ArraySeq.ofDouble = if (xs ne null) new ArraySeq.ofDouble(xs) else null
789789
/** @group conversions-array-to-wrapped-array */
790-
implicit def wrapLongArray(xs: Array[Long]): WrappedArray.ofLong = if (xs ne null) new WrappedArray.ofLong(xs) else null
790+
implicit def wrapLongArray(xs: Array[Long]): ArraySeq.ofLong = if (xs ne null) new ArraySeq.ofLong(xs) else null
791791
/** @group conversions-array-to-wrapped-array */
792-
implicit def wrapFloatArray(xs: Array[Float]): WrappedArray.ofFloat = if (xs ne null) new WrappedArray.ofFloat(xs) else null
792+
implicit def wrapFloatArray(xs: Array[Float]): ArraySeq.ofFloat = if (xs ne null) new ArraySeq.ofFloat(xs) else null
793793
/** @group conversions-array-to-wrapped-array */
794-
implicit def wrapCharArray(xs: Array[Char]): WrappedArray.ofChar = if (xs ne null) new WrappedArray.ofChar(xs) else null
794+
implicit def wrapCharArray(xs: Array[Char]): ArraySeq.ofChar = if (xs ne null) new ArraySeq.ofChar(xs) else null
795795
/** @group conversions-array-to-wrapped-array */
796-
implicit def wrapByteArray(xs: Array[Byte]): WrappedArray.ofByte = if (xs ne null) new WrappedArray.ofByte(xs) else null
796+
implicit def wrapByteArray(xs: Array[Byte]): ArraySeq.ofByte = if (xs ne null) new ArraySeq.ofByte(xs) else null
797797
/** @group conversions-array-to-wrapped-array */
798-
implicit def wrapShortArray(xs: Array[Short]): WrappedArray.ofShort = if (xs ne null) new WrappedArray.ofShort(xs) else null
798+
implicit def wrapShortArray(xs: Array[Short]): ArraySeq.ofShort = if (xs ne null) new ArraySeq.ofShort(xs) else null
799799
/** @group conversions-array-to-wrapped-array */
800-
implicit def wrapBooleanArray(xs: Array[Boolean]): WrappedArray.ofBoolean = if (xs ne null) new WrappedArray.ofBoolean(xs) else null
800+
implicit def wrapBooleanArray(xs: Array[Boolean]): ArraySeq.ofBoolean = if (xs ne null) new ArraySeq.ofBoolean(xs) else null
801801
/** @group conversions-array-to-wrapped-array */
802-
implicit def wrapUnitArray(xs: Array[Unit]): WrappedArray.ofUnit = if (xs ne null) new WrappedArray.ofUnit(xs) else null
802+
implicit def wrapUnitArray(xs: Array[Unit]): ArraySeq.ofUnit = if (xs ne null) new ArraySeq.ofUnit(xs) else null
803803

804804
/** @group conversions-string */
805805
implicit def wrapString(s: String): WrappedString = if (s ne null) new WrappedString(s) else null

src/library/scala/collection/ArrayOps.scala

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package scala
22
package collection
33

4-
import java.lang.{String, Class}
5-
import mutable.{ArrayBuilder, WrappedArray}
6-
import immutable.{ArraySeq, Range}
4+
import mutable.ArrayBuilder
5+
import immutable.Range
76
import scala.reflect.ClassTag
87
import scala.math.{max, min, Ordering}
98

@@ -111,13 +110,12 @@ object ArrayOps {
111110
* the implicit conversion to `ArrayOps` when calling a method (which does not actually
112111
* allocate an instance of `ArrayOps` because it is a value class).
113112
*
114-
* Neither Array` nor `ArrayOps` are proper collection types
115-
* (i.e. they do not extend `Iterable` or even `IterableOnce`). `WrappedArray` and
116-
* `ArraySeq` serve this purpose.
113+
* Neither `Array` nor `ArrayOps` are proper collection types
114+
* (i.e. they do not extend `Iterable` or even `IterableOnce`). `mutable.ArraySeq` and
115+
* `immutable.ArraySeq` serve this purpose.
117116
*
118-
* The difference between this class and `WrappedArray` and `ArraySeq` is that calling
119-
* transformer methods such as `filter` and `map` will yield an array, whereas a `WrappedArray`
120-
* will remain a `WrappedArray`.
117+
* The difference between this class and `ArraySeq`s is that calling transformer methods such as
118+
* `filter` and `map` will yield an array, whereas an `ArraySeq` will remain an `ArraySeq`.
121119
*
122120
* @since 2.8
123121
*
@@ -974,7 +972,7 @@ final class ArrayOps[A](val xs: Array[A]) extends AnyVal {
974972
* ''n'' times in `that`, then the first ''n'' occurrences of `x` will not form
975973
* part of the result, but any following occurrences will.
976974
*/
977-
def diff(that: Seq[_ >: A]): Array[A] = WrappedArray.make(xs).diff(that).array
975+
def diff(that: Seq[_ >: A]): Array[A] = mutable.ArraySeq.make(xs).diff(that).array
978976

979977
/** Computes the multiset intersection between this array and another sequence.
980978
*
@@ -985,7 +983,7 @@ final class ArrayOps[A](val xs: Array[A]) extends AnyVal {
985983
* ''n'' times in `that`, then the first ''n'' occurrences of `x` will be retained
986984
* in the result, but any following occurrences will be omitted.
987985
*/
988-
def intersect(that: Seq[_ >: A]): Array[A] = WrappedArray.make(xs).intersect(that).array
986+
def intersect(that: Seq[_ >: A]): Array[A] = mutable.ArraySeq.make(xs).intersect(that).array
989987

990988
/** Partitions this array into a map of arrays according to some discriminator function.
991989
*
@@ -1015,5 +1013,5 @@ final class ArrayOps[A](val xs: Array[A]) extends AnyVal {
10151013
@`inline` final def toSeq: immutable.Seq[A] = toIndexedSeq
10161014

10171015
def toIndexedSeq: immutable.IndexedSeq[A] =
1018-
ArraySeq.unsafeWrapArray(Array.copyOf(xs, xs.length))
1016+
immutable.ArraySeq.unsafeWrapArray(Array.copyOf(xs, xs.length))
10191017
}

src/library/scala/collection/Factory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ object ClassTagIterableFactory {
588588
}
589589

590590
/**
591-
* @tparam CC Collection type constructor (e.g. `WrappedArray`)
591+
* @tparam CC Collection type constructor (e.g. `ArraySeq`)
592592
*/
593593
trait ClassTagSeqFactory[+CC[_]] extends ClassTagIterableFactory[CC] {
594594
def unapplySeq[A](x: CC[A] @uncheckedVariance): Some[CC[A]] = Some(x) //TODO is uncheckedVariance sound here?

src/library/scala/collection/generic/IsIterableLike.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ object IsIterableLike {
117117
new IsIterableLike[Array[A0]] {
118118
type A = A0
119119
val conversion: Array[A] => IterableOps[A, Iterable, Array[A]] = a => new IterableOps[A, Iterable, Array[A]] {
120-
def toIterable: Iterable[A] = mutable.WrappedArray.make(a)
120+
def toIterable: Iterable[A] = mutable.ArraySeq.make(a)
121121
protected def coll: Array[A] = a
122122
protected def fromSpecificIterable(coll: Iterable[A]): Array[A] = Array.from(coll)
123123
def iterableFactory: IterableFactory[Iterable] = Iterable

0 commit comments

Comments
 (0)