Skip to content

Commit 89b2c44

Browse files
authored
Merge pull request #386 from griggt/scala3-cross
Add cross build for Scala 3
2 parents 9bb13ce + 1da64f9 commit 89b2c44

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ scala:
88
- 2.11.12
99
- 2.12.12
1010
- 2.13.3
11+
- 3.0.0-M1
1112

1213
env:
1314
- SCALAJS_VERSION= ADOPTOPENJDK=8
14-
- SCALAJS_VERSION=0.6.33 ADOPTOPENJDK=8
15-
- SCALAJS_VERSION=1.3.0 ADOPTOPENJDK=8
15+
- SCALAJS_VERSION=1.3.1 ADOPTOPENJDK=8
1616
- SCALAJS_VERSION= ADOPTOPENJDK=11
17-
- SCALAJS_VERSION=0.6.33 ADOPTOPENJDK=11
18-
- SCALAJS_VERSION=1.3.0 ADOPTOPENJDK=11
17+
- SCALAJS_VERSION=1.3.1 ADOPTOPENJDK=11
1918

2019
matrix:
2120

build.sbt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ lazy val root = project
3131
compat212JS,
3232
compat213JVM,
3333
compat213JS,
34+
compat30JVM,
35+
compat30JS,
3436
`scalafix-data211`,
3537
`scalafix-data212`,
3638
`scalafix-data213`,
@@ -51,6 +53,7 @@ lazy val junit = libraryDependencies += "com.novocode" % "junit-interface" % "0.
5153
lazy val scala211 = "2.11.12"
5254
lazy val scala212 = "2.12.12"
5355
lazy val scala213 = "2.13.3"
56+
lazy val scala30 = "3.0.0-M1"
5457

5558
lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform)(
5659
"compat",
@@ -62,7 +65,7 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform
6265
scalacOptions ++= Seq("-feature", "-language:higherKinds", "-language:implicitConversions"),
6366
Compile / unmanagedSourceDirectories += {
6467
val sharedSourceDir = (ThisBuild / baseDirectory).value / "compat/src/main"
65-
if (scalaVersion.value.startsWith("2.13.")) sharedSourceDir / "scala-2.13"
68+
if (scalaVersion.value.startsWith("2.13.") || isDotty.value) sharedSourceDir / "scala-2.13"
6669
else sharedSourceDir / "scala-2.11_2.12"
6770
},
6871
)
@@ -79,13 +82,16 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform
7982
},
8083
)
8184
.jsSettings(
82-
scalacOptions += {
83-
val x = (LocalRootProject / baseDirectory).value.toURI.toString
84-
val y = "https://raw.githubusercontent.com/scala/scala-collection-compat/" + sys.process
85-
.Process("git rev-parse HEAD")
86-
.lineStream_!
87-
.head
88-
s"-P:scalajs:mapSourceURI:$x->$y/"
85+
scalacOptions ++= {
86+
if (isDotty.value) Seq() // Scala.js does not support -P with Scala 3: lampepfl/dotty#9783
87+
else {
88+
val x = (LocalRootProject / baseDirectory).value.toURI.toString
89+
val y = "https://raw.githubusercontent.com/scala/scala-collection-compat/" + sys.process
90+
.Process("git rev-parse HEAD")
91+
.lineStream_!
92+
.head
93+
Seq(s"-P:scalajs:mapSourceURI:$x->$y/")
94+
}
8995
},
9096
Test / fork := false // Scala.js cannot run forked tests
9197
)
@@ -102,6 +108,7 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform
102108
val compat211 = compat(scala211)
103109
val compat212 = compat(scala212)
104110
val compat213 = compat(scala213)
111+
val compat30 = compat(scala30)
105112

106113
lazy val compat211JVM = compat211.jvm
107114
lazy val compat211JS = compat211.js
@@ -110,6 +117,8 @@ lazy val compat212JVM = compat212.jvm
110117
lazy val compat212JS = compat212.js
111118
lazy val compat213JVM = compat213.jvm
112119
lazy val compat213JS = compat213.js
120+
lazy val compat30JVM = compat30.jvm
121+
lazy val compat30JS = compat30.js
113122

114123
lazy val `binary-compat-old` = project
115124
.in(file("binary-compat/old"))

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ package test.scala.collection
1414

1515
import org.junit.{Assert, Test}
1616

17+
import scala.reflect.ClassTag
1718
import scala.collection.compat.immutable.ArraySeq
1819

1920
// The unmodified ArraySeqTest from collection-strawman
@@ -53,22 +54,22 @@ class ArraySeqTest {
5354

5455
def unit1(): Unit = {}
5556
def unit2(): Unit = {}
56-
Assert.assertEquals(unit1, unit2)
57+
Assert.assertEquals(unit1(), unit2())
5758
// unitArray is actually an instance of Immutable[BoxedUnit], the check to which is actually checked slice
5859
// implementation of ofRef
59-
val unitArray: ArraySeq[Unit] = Array(unit1, unit2, unit1, unit2)
60-
check(unitArray, Array(unit1, unit1), Array(unit1, unit1))
60+
val unitArray: ArraySeq[Unit] = Array(unit1(), unit2(), unit1(), unit2())
61+
check(unitArray, Array(unit1(), unit1()), Array(unit1(), unit1()))
6162
}
6263

6364
private def check[T](array: ArraySeq[T],
6465
expectedSliceResult1: ArraySeq[T],
65-
expectedSliceResult2: ArraySeq[T]) {
66+
expectedSliceResult2: ArraySeq[T])(implicit elemTag: ClassTag[T]): Unit = {
6667
Assert.assertEquals(array, array.slice(-1, 4))
6768
Assert.assertEquals(array, array.slice(0, 5))
6869
Assert.assertEquals(array, array.slice(-1, 5))
6970
Assert.assertEquals(expectedSliceResult1, array.slice(0, 2))
7071
Assert.assertEquals(expectedSliceResult2, array.slice(1, 3))
71-
Assert.assertEquals(ArraySeq.empty[Nothing], array.slice(1, 1))
72-
Assert.assertEquals(ArraySeq.empty[Nothing], array.slice(2, 1))
72+
Assert.assertEquals(ArraySeq[T](), array.slice(1, 1))
73+
Assert.assertEquals(ArraySeq[T](), array.slice(2, 1))
7374
}
7475
}

compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ class LazyListLazinessTest {
825825
}
826826

827827
@Test
828-
@Ignore // TODO: enable after we drop Scala.js 0.6.x support
829828
def `#::_properlyLazy`(): Unit = {
830829
// genericCons_properlyLazy(_ #:: _)
831830
genericCons_properlyLazy((hd, tl) => tl.#::(hd))

compat/src/test/scala/test/scala/collection/LazyListTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LazyListTest {
3737
assertEquals(5, wf.map(identity).length) // success instead of NPE
3838
}
3939

40-
@Test(timeout = 10000) // scala/bug#6881
40+
@Test(timeout = 10000L) // scala/bug#6881
4141
def test_reference_equality: Unit = {
4242
// Make sure we're tested with reference equality
4343
val s = LazyList.from(0)
@@ -192,7 +192,7 @@ class LazyListTest {
192192

193193
val cycle1: LazyList[Int] = 1 #:: 2 #:: cycle1
194194
val cycle2: LazyList[Int] = 1 #:: 2 #:: 3 #:: cycle2
195-
@Test(timeout = 10000)
195+
@Test(timeout = 10000L)
196196
def testSameElements(): Unit = {
197197
assert(LazyList().sameElements(LazyList()))
198198
assert(!LazyList().sameElements(LazyList(1)))

project/MultiScalaProject.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ trait MultiScala {
4444
val sourceDir = (ThisBuild / baseDirectory).value / base / "src" / "main"
4545
CrossVersion.partialVersion(scalaVersion.value) match {
4646
case Some((2, n)) if n >= 12 => List(sourceDir / "scala-2.12+")
47+
case Some((3, _)) => List(sourceDir / "scala-2.13")
4748
case _ => Nil
4849
}
4950
},

project/plugins.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
val crossVer = "1.0.0"
22
val scalaJSVersion =
3-
Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("0.6.33")
3+
Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.3.1")
44
val scalaNativeVersion =
55
Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.3.9")
66

7+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6")
78
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
89
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % crossVer)
910
addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)

0 commit comments

Comments
 (0)