8000 Enable Scala 2.13.0 in the linker and all the other artifacts. · sueka/scala-js@1ba6ba8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ba6ba8

Browse files
committed
Enable Scala 2.13.0 in the linker and all the other artifacts.
Partest is not yet enabled in this commit, because a dependency of `partest` 2.13.0, namely `testkit`, was not published. See scala/bug#11529 upstream.
1 parent 21729f3 commit 1ba6ba8

File tree

24 files changed

+343
-168
lines changed

24 files changed

+343
-168
lines changed

Jenkinsfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def allJavaVersions = otherJavaVersions.clone()
420420
allJavaVersions << mainJavaVersion
421421

422422
def mainScalaVersion = "2.12.8"
423-
def mainScalaVersions = ["2.11.12", "2.12.8"]
423+
def mainScalaVersions = ["2.11.12", "2.12.8", "2.13.0"]
424424
def otherScalaVersions = [
425425
"2.11.0",
426426
"2.11.1",
@@ -440,7 +440,6 @@ def otherScalaVersions = [
440440
"2.12.6",
441441
"2.12.7"
442442
]
443-
def noToolsScalaVersions = ["2.13.0"]
444443

445444
// The 'quick' matrix
446445
def quickMatrix = []
@@ -456,11 +455,6 @@ mainScalaVersions.each { scalaVersion ->
456455
quickMatrix.add([task: "partest-fastopt", scala: scalaVersion, java: mainJavaVersion])
457456
}
458457
quickMatrix.add([task: "test-suite-ecma-script5-force-polyfills", scala: mainScalaVersion, java: mainJavaVersion, testSuite: "testSuite"])
459-
noToolsScalaVersions.each { scalaVersion ->
460-
quickMatrix.add([task: "main", scala: scalaVersion, java: mainJavaVersion])
461-
quickMatrix.add([task: "test-suite-ecma-script2015", scala: scalaVersion, java: mainJavaVersion, testSuite: "testSuite"])
462-
quickMatrix.add([task: "test-suite-ecma-script5", scala: scalaVersion, java: mainJavaVersion, testSuite: "testSuite"])
463-
}
464458
allJavaVersions.each { javaVersion ->
465459
quickMatrix.add([task: "tools-sbtplugin", scala: "2.12.8", sbt_version_override: "", java: javaVersion])
466460
quickMatrix.add([task: "tools", scala: "2.10.7", java: javaVersion])

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/JSEnvSuite.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package org.scalajs.jsenv.test
1414

1515
import org.scalajs.jsenv.JSEnv
1616

17-
import scala.collection.JavaConverters._
1817
import scala.reflect.ClassTag
1918

2019
import org.junit.runner.Runner
@@ -40,7 +39,7 @@ abstract class JSEnvSuite(private[test] val config: JSEnvSuiteConfig)
4039

4140
/** Runner for a [[JSEnvSuite]]. May only be used on subclasses of [[JSEnvSuite]]. */
4241
final class JSEnvSuiteRunner(root: Class[_], config: JSEnvSuiteConfig)
43-
extends Suite(root, JSEnvSuiteRunner.getRunners(config).asJava) {
42+
extends Suite(root, JSEnvSuiteRunner.getRunners(config)) {
4443

4544
/** Constructor for reflective instantiation via `@RunWith`. */
4645
def this(suite: Class[_ <: JSEnvSuite]) =
@@ -56,16 +55,19 @@ private object JSEnvSuiteRunner {
5655
.map { case (name, value) => s"$name = $value" }
5756
.mkString("[", ", ", "]")
5857

59-
val paramValues = config +: params.map(_._2)
58+
val paramValues = new java.util.LinkedList[AnyRef]
59+
paramValues.add(config)
60+
for (param <- params)
61+
paramValues.add(param._2)
6062

6163
10000 new BlockJUnit4ClassRunnerWithParameters(
62-
new TestWithParameters(name, new TestClass(t.runtimeClass), paramValues.asJava))
64+
new TestWithParameters(name, new TestClass(t.runtimeClass), paramValues))
6365
}
6466

65-
private def getRunners(config: JSEnvSuiteConfig): List[Runner] = {
67+
private def getRunners(config: JSEnvSuiteConfig): java.util.List[Runner] = {
6668
import java.lang.Boolean.{TRUE, FALSE}
6769

68-
List(
70+
java.util.Arrays.asList(
6971
r[RunTests](config, "withCom" -> FALSE),
7072
r[RunTests](config, "withCom" -> TRUE),
7173
r[TimeoutRunTests](config, "withCom" -> FALSE),

linker/jvm/src/main/scala/org/scalajs/linker/backend/closure/ClosureLinkerBackend.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
package org.scalajs.linker.backend.closure
1414

15-
import scala.collection.JavaConverters._
1615
import scala.concurrent._
1716

1817
import java.io._
@@ -92,7 +91,7 @@ final class ClosureLinkerBackend(config: LinkerBackendImpl.Config)
9291
}
9392

9493
// Compile the module
95-
val closureExterns = List(
94+
val closureExterns = java.util.Arrays.asList(
9695
ClosureSource.fromCode("ScalaJSExterns.js", ClosureLinkerBackend.ScalaJSExterns),
9796
ClosureSource.fromCode("ScalaJSGlobalRefs.js", makeExternsForGlobalRefs(globalRefs)),
9897
ClosureSource.fromCode("ScalaJSExportExterns.js", makeExternsForExports(topLevelVarDeclarations, unit)))
@@ -101,7 +100,7 @@ final class ClosureLinkerBackend(config: LinkerBackendImpl.Config)
101100

102101
val result = logger.time("Closure: Compiler pass") {
103102
compiler.compileModules(
104-
closureExterns.asJava, List(module).asJava, options)
103+
closureExterns, java.util.Arrays.asList(module), options)
105104
}
106105

107106
if (!result.success) {

linker/jvm/src/main/scala/org/scalajs/linker/backend/closure/ClosureModuleBuilder.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private[closure] class ClosureModuleBuilder(
3030
relativizeBaseURI: Option[URI] = None) extends JSBuilder {
3131

3232
private val transformer = new ClosureAstTransformer(relativizeBaseURI)
33-
private val treeBuf = mutable.ListBuffer.empty[Node]
33+
private val treeBuf = List.newBuilder[Node]
3434

3535
def addJSTree(tree: Tree): Unit = {
3636
/* Top-level `js.Block`s must be explicitly flattened here.
@@ -54,8 +54,9 @@ private[closure] class ClosureModuleBuilder(
5454
def result(): JSModule = {
5555
val module = new JSModule("Scala.js")
5656

57-
if (treeBuf.nonEmpty) {
58-
val root = transformer.setNodePosition(IR.script(treeBuf: _*), NoPosition)
57+
val trees = treeBuf.result()
58+
if (trees.nonEmpty) {
59+
val root = transformer.setNodePosition(IR.script(trees: _*), NoPosition)
5960
val ast = new ClosureModuleBuilder.ScalaJSSourceAst(root)
6061
module.add(new CompilerInput(ast, ast.getInputId(), false))
6162
}

linker/jvm/src/main/scala/org/scalajs/linker/frontend/optimizer/ParIncOptimizer.scala

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ final class ParIncOptimizer(config: CommonPhaseConfig)
4141
def emptyParIterable[V]: ParIterable[V] = ParArray.empty
4242

4343
// Operations on ParMap
44+
def isEmpty[K, V](map: ParMap[K, V]): Boolean = map.isEmpty
45+
def forceGet[K, V](map: ParMap[K, V], k: K): V = map(k)
46+
def get[K, V](map: ParMap[K, V], k: K): Option[V] = map.get(k)
4447
def put[K, V](map: ParMap[K, V], k: K, v: V): Unit = map.put(k, v)
4548
def remove[K, V](map: ParMap[K, V], k: K): Option[V] = map.remove(k)
4649

@@ -51,16 +54,19 @@ final class ParIncOptimizer(config: CommonPhaseConfig)
5154
}
5255
}
5356

57+
def valuesForeach[K, V, U](map: ParMap[K, V])(f: V => U): Unit =
58+
map.values.foreach(f)
59+
5460
// Operations on AccMap
5561
def acc[K, V](map: AccMap[K, V], k: K, v: V): Unit =
5662
map.getOrPut(k, AtomicAcc.empty) += v
5763

58-
def getAcc[K, V](map: AccMap[K, V], k: K): GenIterable[V] =
64+
def getAcc[K, V](map: AccMap[K, V], k: K): ParIterable[V] =
5965
map.get(k).fold[Iterable[V]](Nil)(_.removeAll()).toParArray
6066

6167
def parFlatMapKeys[A, B](map: AccMap[A, _])(
62-
f: A => GenTraversableOnce[B]): GenIterable[B] =
63-
map.keys.flatMap(f).toParArray
68+
f: A => Option[B]): ParIterable[B] =
69+
map.keys.flatMap(f(_)).toParArray
6470

6571
// Operations on ParIterable
6672
def prepAdd[V](it: ParIterable[V]): Addable[V] =
@@ -71,6 +77,12 @@ final class ParIncOptimizer(config: CommonPhaseConfig)
7177

7278
def finishAdd[V](addable: Addable[V]): ParIterable[V] =
7379
addable.removeAll().toParArray
80+
81+
def foreach[V, U](it: ParIterable[V])(f: V => U): Unit =
82+
it.foreach(f)
83+
84+
def filter[V](it: ParIterable[V])(f: V => Boolean): ParIterable[V] =
85+
it.filter(f)
7486
}
7587

7688
private val _interfaces = TrieMap.empty[String, InterfaceType]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package org.scalajs.linker
14+
15+
import scala.collection.mutable
16+
17+
private[linker] object CollectionsCompat {
18+
implicit class MutableMapCompatOps[K, V](val __self: mutable.Map[K, V])
19+
extends AnyVal {
20+
21+
// filterInPlace replaces retain
22+
def filterInPlace(p: (K, V) => Boolean): Unit = {
23+
// Believe it or not, this is the implementation of `retain` in 2.12.x:
24+
25+
// scala/bug#7269 toList avoids ConcurrentModificationException
26+
for ((k, v) <- __self.toList) {
27+
if (!p(k, v))
28+
__self -= k
29+
}
30+
}
31+
}
32+
}

linker/shared/src/main/scala/org/scalajs/linker/analyzer/Analysis.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ trait Analysis {
3333
import Analysis._
3434

3535
def classInfos: scala.collection.Map[String, ClassInfo]
36-
def errors: Seq[Error]
36+
def errors: scala.collection.Seq[Error]
3737
}
3838

3939
object Analysis {
@@ -62,8 +62,8 @@ object Analysis {
6262
def encodedName: String
6363
def kind: ClassKind
6464
def superClass: Option[ClassInfo]
65-
def interfaces: Seq[ClassInfo]
66-
def ancestors: Seq[ClassInfo]
65+
def interfaces: scala.collection.Seq[ClassInfo]
66+
def ancestors: scala.collection.Seq[ClassInfo]
6767
def nonExistent: Boolean
6868
/** For a Scala class, it is instantiated with a `New`; for a JS class,
6969
* its constructor is accessed with a `JSLoadConstructor` or because it
@@ -74,8 +74,8 @@ object Analysis {
7474
def isModuleAccessed: Boolean
7575
def areInstanceTestsUsed: Boolean
7676
def isDataAccessed: Boolean
77-
def linkedFrom: Seq[From]
78-
def instantiatedFrom: Seq[From]
77+
def linkedFrom: scala.collection.Seq[From]
78+
def instantiatedFrom: scala.collection.Seq[From]
7979
def methodInfos(
8080
namespace: MemberNamespace): scala.collection.Map[String, MethodInfo]
8181

@@ -97,8 +97,8 @@ object Analysis {
9797
def isExported: Boolean
9898
def isReflProxy: Boolean
9999
def isReachable: Boolean
100-
def calledFrom: Seq[From]
101-
def instantiatedSubclasses: Seq[ClassInfo]
100+
def calledFrom: scala.collection.Seq[From]
101+
def instantiatedSubclasses: scala.collection.Seq[ClassInfo]
102102
def nonExistent: Boolean
103103
def syntheticKind: MethodSyntheticKind
104104

linker/shared/src/main/scala/org/scalajs/linker/analyzer/Analyzer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private final class Analyzer(config: CommonPhaseConfig,
5555

5656
def classInfos: scala.collection.Map[String, Analysis.ClassInfo] = _loadedClassInfos
5757

58-
def errors: Seq[Error] = _errors
58+
def errors: scala.collection.Seq[Error] = _errors
5959

6060
def computeReachability(): Future[Unit] = {
6161
require(_classInfos.isEmpty, "Cannot run the same Analyzer multiple times")
@@ -1150,7 +1150,7 @@ object Analyzer {
11501150
}
11511151

11521152
trait InputProvider {
1153-
def classesWithEntryPoints(): TraversableOnce[String]
1153+
def classesWithEntryPoints(): Iterable[String]
11541154

11551155
def loadInfo(encodedName: String)(implicit ec: ExecutionContext): Option[Future[Infos.ClassInfo]]
11561156
}

linker/shared/src/main/scala/org/scalajs/linker/analyzer/Infos.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ object Infos {
136136
this
137137
}
138138

139-
def addInterfaces(interfaces: TraversableOnce[String]): this.type = {
139+
def addInterfaces(interfaces: List[String]): this.type = {
140140
this.interfaces ++= interfaces
141141
this
142142
}
@@ -319,7 +319,7 @@ object Infos {
319319
def result(): MethodInfo = {
320320
def toMapOfLists[A](
321321
m: mutable.Map[String, mutable.Set[A]]): Map[String, List[A]] = {
322-
m.mapValues(_.toList).toMap
322+
m.map(kv => kv._1 -> kv._2.toList).toMap
323323
}
324324

325325
MethodInfo(

linker/shared/src/main/scala/org/scalajs/linker/backend/emitter/Emitter.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.scalajs.logging._
2525
import org.scalajs.linker._
2626
import org.scalajs.linker.standard._
2727
import org.scalajs.linker.backend.javascript.{Trees => js, _}
28+
import org.scalajs.linker.CollectionsCompat.MutableMapCompatOps
2829

2930
import GlobalRefUtils._
3031

@@ -402,7 +403,7 @@ final class Emitter private (config: CommonPhaseConfig,
402403
logger.debug(
403404
s"Emitter: Method tree cache stats: resued: $statsMethodsReused -- "+
404405
s"invalidated: $statsMethodsInvalidated")
405-
classCaches.retain((_, c) => c.cleanAfterRun())
406+
classCaches.filterInPlace((_, c) => c.cleanAfterRun())
406407
}
407408

408409
/** Generates all the desugared classes.
@@ -658,7 +659,7 @@ final class Emitter private (config: CommonPhaseConfig,
658659

659660
private def mergeVersions(v1: Option[String],
660661
v2: Option[String]): Option[String] = {
661-
v1.flatMap(s1 => v2.map(s2 => s1.length + "-" + s1 + s2))
662+
v1.flatMap(s1 => v2.map(s2 => "" + s1.length + "-" + s1 + s2))
662663
}
663664

664665
private def getClassTreeCache(linkedClass: LinkedClass): DesugaredClassCache =
@@ -722,7 +723,7 @@ final class Emitter private (config: CommonPhaseConfig,
722723
}
723724

724725
def cleanAfterRun(): Boolean = {
725-
_methodCaches.foreach(_.retain((_, c) => c.cleanAfterRun()))
726+
_methodCaches.foreach(_.filterInPlace((_, c) => c.cleanAfterRun()))
726727

727728
if (_constructorCache.exists(!_.cleanAfterRun()))
728729
_constructorCache = None
@@ -837,9 +838,9 @@ private object Emitter {
837838
cond(!coreSpec.esFeatures.allowBigIntsForLongs) {
838839
multiple(
839840
instanceTests(LongImpl.RuntimeLongClass),
840-
instantiateClass(LongImpl.RuntimeLongClass, LongImpl.AllConstructors),
841-
callMethods(LongImpl.RuntimeLongClass, LongImpl.AllMethods),
842-
callOnModule(LongImpl.RuntimeLongModuleClass, LongImpl.AllModuleMethods)
841+
instantiateClass(LongImpl.RuntimeLongClass, LongImpl.AllConstructors.toList),
842+
callMethods(LongImpl.RuntimeLongClass, LongImpl.AllMethods.toList),
843+
callOnModule(LongImpl.RuntimeLongModuleClass, LongImpl.AllModuleMethods.toList)
843844
)
844845
}
845846
)

0 commit comments

Comments
 (0)
0