Skip to content

Commit

Permalink
Update Scala to 2.12.13 (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Jan 15, 2021
1 parent 7548ac6 commit a0eee40
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 24 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- master
jobs:
unit-11-2_12_12:
unit-11-2_12_13:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -16,8 +16,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: '11'
- run: ./mill -i unitTest 2.12.12
unit-8-2_12_12:
- run: ./mill -i unitTest 2.12.13
unit-8-2_12_13:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +26,7 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: '8'
- run: ./mill -i unitTest 2.12.12
- run: ./mill -i unitTest 2.12.13

unit-8-2_13_4:
runs-on: ubuntu-latest
Expand All @@ -39,7 +39,7 @@ jobs:
java-version: '8'
- run: ./mill -i unitTest 2.13.4

integration-11-2_12_12:
integration-11-2_12_13:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -48,8 +48,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: '11'
- run: ./mill -i integrationTest 2.12.12
integration-8-2_12_12:
- run: ./mill -i integrationTest 2.12.13
integration-8-2_12_13:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -58,7 +58,7 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: '8'
- run: ./mill -i integrationTest 2.12.12
- run: ./mill -i integrationTest 2.12.13

integration-8-2_13_4:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package ammonite.interp

import ammonite.runtime.Classpath

import scala.reflect.internal.util.Position
import scala.reflect.io.FileZipArchive
import scala.tools.nsc
import scala.tools.nsc.classpath.{AggregateClassPath, ZipAndJarClassPathFactory}
import scala.tools.nsc.{Global, Settings}
import scala.tools.nsc.interactive.{InteractiveAnalyzer, Global => InteractiveGlobal}
import scala.tools.nsc.plugins.Plugin
import scala.tools.nsc.reporters.Reporter
import scala.tools.nsc.typechecker.Analyzer

object CompilerCompatibility {

def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = {
new { val global: g.type = g } with Analyzer {
override def findMacroClassLoader() = cl
}
}

def interactiveAnalyzer(g: InteractiveGlobal,
cl: ClassLoader): InteractiveAnalyzer { val global: g.type } = {
new { val global: g.type = g } with InteractiveAnalyzer
}

def importInfo(g: Global)(t: g.Import) =
new g.analyzer.ImportInfo(t, 0)

def initGlobal(settings: Settings,
reporter: Reporter,
jcp: AggregateClassPath,
evalClassloader: ClassLoader,
createPlugins: Global => List[Plugin]): Global = {

new nsc.Global(settings, reporter) { g =>
override lazy val plugins = createPlugins(g)

override def classPath = jcp

override lazy val platform: ThisPlatform = new GlobalPlatform {
override val global = g
override val settings = g.settings
override val classPath = jcp
}

override lazy val analyzer = CompilerCompatibility.analyzer(g, evalClassloader)
}
}

def createZipJarFactory(arc: FileZipArchive, settings: Settings) = {
ZipAndJarClassPathFactory.create(arc, settings, new scala.tools.nsc.CloseableRegistry())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ammonite.interp

import ammonite.runtime.Classpath

import scala.reflect.internal.util.Position
import scala.reflect.io.FileZipArchive
import scala.tools.nsc
import scala.tools.nsc.classpath.{AggregateClassPath, ZipAndJarClassPathFactory}
import scala.tools.nsc.{Global, Settings}
import scala.tools.nsc.interactive.{InteractiveAnalyzer, Global => InteractiveGlobal}
import scala.tools.nsc.plugins.Plugin
import scala.tools.nsc.reporters.FilteringReporter
import scala.tools.nsc.typechecker.Analyzer

object MakeReporter {

type Reporter = scala.tools.nsc.reporters.Reporter

def makeReporter(errorLogger: (Position, String) => Unit,
warningLogger: (Position, String) => Unit,
infoLogger: (Position, String) => Unit,
outerSettings: Settings): Reporter =
new FilteringReporter {

def doReport(pos: scala.reflect.internal.util.Position,
msg: String,
severity: Severity): Unit =
display(pos, msg, severity)

def display(pos: Position, msg: String, severity: Severity) =
severity match{
case ERROR =>
Classpath.traceClasspathProblem(s"ERROR: $msg")
errorLogger(pos, msg)
case WARNING =>
warningLogger(pos, msg)
case INFO =>
infoLogger(pos, msg)
}

def settings = outerSettings
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AmmoniteBuildServer(
Dependency.of(
"org.scalameta",
"semanticdb-scalac_" + scala.util.Properties.versionNumberString,
"4.4.0"
"4.4.6"
)
),
root,
Expand Down
6 changes: 5 additions & 1 deletion amm/repl/src/test/scala/ammonite/session/BuiltinTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ object BuiltinTests extends TestSuite{
// not sure why that one doesn't pass in 2.13
// even disabling the noimports and imports settings instead of setting noimports to false
// doesn't seem to reinstate imports
if (TestUtils.scala2_12) check.session(s"""
def sv = scala.util.Properties.versionNumberString
// In 2.12.13, I would have expected things like
// interp.configureCompiler(_.settings.Wconf.tryToSet(List("any:wv", "cat=unchecked:ws")))
// to re-instate the expected warning below, to no avail :|
if (TestUtils.scala2_12 && sv.stripPrefix("2.12.").toInt <= 12) check.session(s"""
@ // Disabling default Scala imports

@ List(1, 2, 3) + "lol"
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ environment:
matrix:
- JAVA_OPTS: -Dfile.encoding=UTF8
JAVA_HOME: C:\Program Files\Java\jdk9
TEST_TASKS: terminal[2.12.12].test amm.repl[2.12.12].test terminal[2.13.4].test amm.repl[2.13.4].test
TEST_TASKS: terminal[2.12.13].test amm.repl[2.12.13].test terminal[2.13.4].test amm.repl[2.13.4].test

- JAVA_OPTS: -Dfile.encoding=UTF8
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
TEST_TASKS: integration[2.12.12].test integration[2.13.4].test
TEST_TASKS: integration[2.12.13].test integration[2.13.4].test

install:
- SET MILL_URL=https://github.com/lihaoyi/mill/releases/download/0.8.0/0.8.0-assembly
Expand Down
24 changes: 12 additions & 12 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ val commitsSinceTaggedVersion = {
}


val binCrossScalaVersions = Seq("2.12.12", "2.13.4")
val binCrossScalaVersions = Seq("2.12.13", "2.13.4")
def isScala2_12_10OrLater(sv: String): Boolean = {
(sv.startsWith("2.12.") && sv.stripPrefix("2.12.").length > 1) || (sv.startsWith("2.13.") && sv != "2.13.0")
}
val fullCrossScalaVersions = Seq(
"2.12.1", "2.12.2", "2.12.3", "2.12.4", "2.12.6", "2.12.7", "2.12.8", "2.12.9", "2.12.10", "2.12.11", "2.12.12",
"2.12.1", "2.12.2", "2.12.3", "2.12.4", "2.12.6", "2.12.7", "2.12.8", "2.12.9", "2.12.10", "2.12.11", "2.12.12", "2.12.13",
"2.13.0", "2.13.1", "2.13.2", "2.13.3", "2.13.4"
)

Expand Down Expand Up @@ -65,12 +65,10 @@ trait AmmInternalModule extends mill.scalalib.CrossSbtModule{
val extraDir =
if (sv.startsWith("2.12.")) {
val patch = sv.stripPrefix("2.12.").takeWhile(_.isDigit).toInt
val dirName =
if (patch <= 8)
"scala-2.12.0_8"
else
"scala-2.12.9+"
Seq(PathRef(millSourcePath / "src" / "main" / dirName))
val dirName0 = if (patch <= 8) "scala-2.12.0_8" else "scala-2.12.9+"
val dirNames1 = if (patch <= 12) Seq("scala-2.12.0_12") else Nil
val dirNames = Seq(dirName0) ++ dirNames1
dirNames.map(dirName => PathRef(millSourcePath / "src" / "main" / dirName))
} else
Nil

Expand All @@ -79,10 +77,12 @@ trait AmmInternalModule extends mill.scalalib.CrossSbtModule{
else millSourcePath / "src" / "main" / "scala-not-2.12.10-2.13.1+"
)
val extraDir3 =
if (!sv.startsWith("2.13.") || sv == "2.13.0")
PathRef(millSourcePath / "src" / "main" / "scala-not-2.13.1+")
else
if (sv.startsWith("2.13.") && sv != "2.13.0")
PathRef(millSourcePath / "src" / "main" / "scala-2.13.1+")
else if (sv.startsWith("2.12.") && sv.stripPrefix("2.12.").toInt >= 13)
PathRef(millSourcePath / "src" / "main" / "scala-2.12.13+")
else
PathRef(millSourcePath / "src" / "main" / "scala-not-2.12.13+-2.13.1+")

super.sources() ++ extraDir ++ Seq(extraDir2, extraDir3)
}
Expand Down Expand Up @@ -212,7 +212,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){
def crossFullScalaVersion = true
def ivyDeps = Agg(
ivy"ch.epfl.scala:bsp4j:$bspVersion",
ivy"org.scalameta::trees:4.4.0",
ivy"org.scalameta::trees:4.4.6",
ivy"org.scala-lang:scala-compiler:$crossScalaVersion",
ivy"org.scala-lang:scala-reflect:$crossScalaVersion",
ivy"com.lihaoyi::scalaparse:2.3.0",
Expand Down

0 comments on commit a0eee40

Please sign in to comment.