Skip to content

Commit 563ebaf

Browse files
committed
Add support for Scala 2.13-M4
1 parent 91a96d8 commit 563ebaf

File tree

21 files changed

+161
-112
lines changed

21 files changed

+161
-112
lines changed

build.sbt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sbt.CrossVersion
2+
13
sourceDirectory := file("dummy source directory")
24

35
scalaVersionSettings
@@ -11,7 +13,9 @@ lazy val travisCommit = Option(System.getenv().get("TRAVIS_COMMIT"))
1113

1214
lazy val scalaVersionSettings = Seq(
1315
scalaVersion := "2.12.3",
14-
crossScalaVersions := Seq("2.10.6", "2.11.11", "2.13.0-M2", scalaVersion.value)
16+
// Temporary: we will eventually use 2.13.0-M4, which will be published to maven central
17+
resolvers += "scala-pr" at "https://scala-ci.typesafe.com/artifactory/scala-integration/",
18+
crossScalaVersions := Seq("2.10.6", "2.11.11", "2.13.0-pre-c577876", scalaVersion.value)
1519
)
1620

1721
lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
@@ -46,6 +50,17 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
4650

4751
unmanagedSourceDirectories in Test += (baseDirectory in LocalRootProject).value / "src" / "test" / "scala",
4852

53+
unmanagedSourceDirectories in Compile ++= {
54+
(unmanagedSourceDirectories in Compile).value.map { dir =>
55+
CrossVersion.partialVersion(scalaVersion.value) match {
56+
case Some((2, 13)) => file(dir.getPath ++ "-2.13")
57+
case _ => file(dir.getPath ++ "-2.10-2.12")
58+
}
59+
}
60+
},
61+
62+
libraryDependencies += "org.scala-lang" %% "scala-collection-compat" % "0.1-SNAPSHOT",
63+
4964
resolvers += "sonatype" at "https://oss.sonatype.org/content/repositories/releases",
5065

5166
javacOptions += "-Xmx1024M",
@@ -55,7 +70,7 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
5570
"-encoding", "UTF-8",
5671
"-feature",
5772
"-unchecked",
58-
"-Xfatal-warnings",
73+
//"-Xfatal-warnings", Disabled because “import scala.collection.compat._” causes “Unused import” warnings on 2.13.
5974
"-Xfuture",
6075
"-Yno-adapted-args",
6176
"-Ywarn-dead-code",

doc/UserGuide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,15 +873,15 @@ object CounterSpecification extends Commands {
873873
* (a singleton [[Sut]]), implement this method the following way:
874874
*
875875
* {{{
876-
* def canCreateNewSut(newState: State, initSuts: Traversable[State]
877-
* runningSuts: Traversable[Sut]
876+
* def canCreateNewSut(newState: State, initSuts: Iterable[State]
877+
* runningSuts: Iterable[Sut]
878878
* ) = {
879879
* initSuts.isEmpty && runningSuts.isEmpty
880880
* }
881881
* }}}
882882
*/
883-
def canCreateNewSut(newState: State, initSuts: Traversable[State],
884-
runningSuts: Traversable[Sut]): Boolean = true
883+
def canCreateNewSut(newState: State, initSuts: Iterable[State],
884+
runningSuts: Iterable[Sut]): Boolean = true
885885

886886
/** The precondition for the initial state, when no commands yet have
887887
* run. This is used by ScalaCheck when command sequences are shrinked

examples/commands-leveldb/src/test/scala/CommandsLevelDB.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ object LevelDBSpec extends Commands {
3030
def path = s"db_$name"
3131
}
3232

33-
def canCreateNewSut(newState: State, initSuts: Traversable[State],
34-
runningSuts: Traversable[Sut]
33+
def canCreateNewSut(newState: State, initSuts: Iterable[State],
34+
runningSuts: Iterable[Sut]
3535
) = {
3636
!initSuts.exists(_.name == newState.name) &&
3737
!runningSuts.exists(_.name == newState.name)

examples/commands-nix/src/test/scala/CommandsNix.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ object MachineSpec extends Commands {
100100
type Sut = Map[String, org.libvirt.Domain]
101101

102102
// TODO we should check for example total amount of memory used here
103-
def canCreateNewSut(newState: State, initSuts: Traversable[State],
104-
runningSuts: Traversable[Sut]
103+
def canCreateNewSut(newState: State, initSuts: Iterable[State],
104+
runningSuts: Iterable[Sut]
105105
): Boolean = true
106106

107107
def newSut(state: State): Sut = {

examples/commands-redis/src/test/scala/CommandsRedis.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ object RedisSpec extends Commands {
2626
connected: Boolean
2727
)
2828

29-
def canCreateNewSut(newState: State, initSuts: Traversable[State],
30-
runningSuts: Traversable[Sut]
29+
def canCreateNewSut(newState: State, initSuts: Iterable[State],
30+
runningSuts: Iterable[Sut]
3131
): Boolean = {
3232
initSuts.isEmpty && runningSuts.isEmpty
3333
}

jvm/src/test/scala/org/scalacheck/GenSpecification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ object GenSpecification extends Properties("Gen") {
203203
property("distributed pick") = {
204204
val lst = (0 to 7).toIterable
205205
val n = 2
206-
forAll(pick(n, lst)) { xs: Seq[Int] =>
206+
forAll(pick(n, lst)) { xs: collection.Seq[Int] =>
207207
xs.map { x: Int =>
208208
Prop.collect(x) {
209209
xs.size == n

jvm/src/test/scala/org/scalacheck/commands/CommandsSpecification.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ object CommandsSpecification extends Properties("Commands") {
3030

3131
override def shrinkState: Shrink[Int] = implicitly
3232

33-
def canCreateNewSut(newState: State, initSuts: Traversable[State],
34-
runningSuts: Traversable[Sut]) = true
33+
def canCreateNewSut(newState: State, initSuts: Iterable[State],
34+
runningSuts: Iterable[Sut]) = true
3535

3636
def newSut(state: State): Sut = Counter(state)
3737

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.0.4
1+
sbt.version=1.1.0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.scalacheck.util
2+
3+
import java.util
4+
import java.util.ArrayList
5+
6+
import scala.collection.mutable
7+
8+
private[scalacheck] class ArrayListBuilder[T]
9+
extends mutable.Builder[T, util.ArrayList[T]] {
10+
val al = new ArrayList[T]
11+
def +=(x: T) = {
12+
al.add(x)
13+
this
14+
}
15+
def clear() = al.clear()
16+
def result() = al
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.scalacheck.util
2+
3+
import java.util
4+
import java.util.ArrayList
5+
6+
import scala.collection.mutable
7+
8+
private[scalacheck] class ArrayListBuilder[T]
9+
extends mutable.Builder[T, util.ArrayList[T]] {
10+
val al = new ArrayList[T]
11+
def addOne(x: T) = {
12+
al.add(x)
13+
this
14+
}
15+
def clear() = al.clear()
16+
def result() = al
17+
}

0 commit comments

Comments
 (0)