Skip to content

Commit b87ac8a

Browse files
committed
Move everything into the scala.colleciton.compat package
Fixes #30 Using `scala.collection.compat.imm` (not `.immutable`) to avoid name clashes with `scala.collection.immutable`.
1 parent 928cc63 commit b87ac8a

File tree

10 files changed

+31
-22
lines changed

10 files changed

+31
-22
lines changed

src/main/scala-2.11_2.12/scala/collection/BuildFrom.scala renamed to src/main/scala-2.11_2.12/scala/collection/compat/BuildFrom.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package scala.collection
1+
package scala.collection.compat
22

33
import scala.collection.generic.CanBuildFrom
4+
import scala.collection.{Iterable, mutable}
45

56
/** Builds a collection of type `C` from elements of type `A` when a source collection of type `From` is available.
67
* Implicit instances of `BuildFrom` are available for all collection types.

src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package scala.collection.compat
1+
package scala.collection
2+
package compat
23

34
import scala.collection.generic.CanBuildFrom
45
import scala.collection.mutable.Builder
5-
import scala.collection.{immutable, mutable}
66

77
private[compat] object CompatImpl {
88
def simpleCBF[A, C](f: => Builder[A, C]): CanBuildFrom[Any, A, C] = new CanBuildFrom[Any, A, C] {

src/main/scala-2.11_2.12/scala/collection/Factory.scala renamed to src/main/scala-2.11_2.12/scala/collection/compat/Factory.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package scala.collection
1+
package scala.collection.compat
22

33
import scala.collection.generic.CanBuildFrom
4+
import scala.collection.{TraversableOnce, mutable}
45

56
/**
67
* A factory that builds a collection of type `C` with elements of type `A`.
@@ -33,4 +34,4 @@ object Factory {
3334
implicit def fromCanBuildFromConversion[X, A, C](x: X)(implicit toCanBuildFrom: X => CanBuildFrom[Nothing, A, C]): Factory[A, C] =
3435
fromCanBuildFrom(toCanBuildFrom(x))
3536

36-
}
37+
}

src/main/scala-2.11_2.12/scala/collection/immutable/ArraySeq.scala renamed to src/main/scala-2.11_2.12/scala/collection/compat/imm/ArraySeq.scala

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
package scala
2-
package collection
3-
package immutable
1+
package scala.collection.compat.imm
42

5-
import scala.reflect.ClassTag
6-
import scala.runtime.BoxedUnit
3+
import java.util.Arrays
4+
5+
import scala.annotation.unchecked.uncheckedVariance
6+
import scala.collection.AbstractSeq
77
import scala.collection.generic._
8-
import scala.collection.mutable.{Builder, ArrayBuilder, ArrayBuffer, WrappedArrayBuilder}
8+
import scala.collection.immutable.IndexedSeq
9+
import scala.collection.mutable.{ArrayBuilder, Builder, WrappedArrayBuilder}
10+
import scala.reflect.ClassTag
911
import scala.util.hashing.MurmurHash3
10-
import scala.annotation.unchecked.uncheckedVariance
11-
12-
import java.util.Arrays
1312

1413
/**
1514
* An immutable array.
@@ -42,9 +41,6 @@ abstract class ArraySeq[+T]
4241
/** The underlying array */
4342
def unsafeArray: Array[T @uncheckedVariance]
4443

45-
private def elementClass: Class[_] =
46-
unsafeArray.getClass.getComponentType
47-
4844
override def stringPrefix = "ArraySeq"
4945

5046
/** Clones this object, including the underlying Array. */

src/main/scala-2.11_2.12/scala/collection/compat/package.scala

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package scala.collection
22

33
import scala.collection.generic._
4-
import scala.collection.mutable.Builder
54
import scala.reflect.ClassTag
65

76
/** The collection compatibility API */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package scala.collection.compat
2+
3+
package object imm {
4+
type ArraySeq[+T] = scala.collection.immutable.ArraySeq[T]
5+
val ArraySeq = scala.collection.immutable.ArraySeq
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package scala.collection
22

3-
// Empty dummy package to allow cross-building with Scala 2.12
43
package object compat {
4+
type Factory[-A, +C] = scala.collection.Factory[A, C]
5+
val Factory = scala.collection.Factory
6+
7+
type BuildFrom[-From, -A, +C] = scala.collection.BuildFrom[From, A, C]
8+
val BuildFrom = scala.collection.BuildFrom
9+
10+
type IterableOnce[+X] = scala.collection.IterableOnce[X]
511
}

src/test/scala/test/scala/collection/ArraySeqTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package test.scala.collection
22

33
import org.junit.{Assert, Test}
44

5-
import scala.collection.immutable.ArraySeq
5+
import scala.collection.compat.imm.ArraySeq
66

77
// The unmodified ArraySeqTest from collection-strawman
88
class ArraySeqTest {

src/test/scala/test/scala/collection/BuildFromTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.junit.Test
55
import scala.collection.compat._
66
import scala.collection.immutable.{HashMap, TreeMap, TreeSet}
77
import scala.collection.mutable.{ArrayBuffer, Builder, ListBuffer}
8-
import scala.collection.{BitSet, BuildFrom, SortedMap, SortedSet, immutable, mutable}
8+
import scala.collection.{BitSet, SortedMap, SortedSet, immutable, mutable}
99

1010
// Tests copied from the 2.13 scala-library
1111
class BuildFromTest {

src/test/scala/test/scala/collection/FactoryTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package test.scala.collection
33
import org.junit.{Assert, Test}
44

55
import scala.collection.compat._
6-
import scala.collection.{BitSet, Factory, immutable, mutable}
6+
import scala.collection.{BitSet, immutable, mutable}
77

88
class FactoryTest {
99

0 commit comments

Comments
 (0)