From 2831d97820abe4548960c1c3900abd96865a88da Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 12 Oct 2024 21:34:52 +0200 Subject: [PATCH] More Scala 3 compatibility backports (#3724) Turned on `-Xsource:3` and fixed the most obvious syntax issues, silenced the other less-trivial warnings --- build.mill | 7 ++++++- .../output-directory/src/OutputDirectoryLockTests.scala | 2 +- main/eval/test/src/mill/eval/ModuleTests.scala | 2 +- runner/src/mill/runner/MillBuildRootModule.scala | 2 +- scalalib/src/mill/scalalib/CoursierModule.scala | 4 ++-- .../worker/src/mill/scalalib/worker/ZincWorkerImpl.scala | 4 ++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/build.mill b/build.mill index 365a2225c13..9c2c741026a 100644 --- a/build.mill +++ b/build.mill @@ -411,7 +411,12 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul "-P:acyclic:force", "-feature", "-Xlint:unused", - "-Xlint:adapted-args" + "-Xlint:adapted-args", + "-Xsource:3", + "-Wconf:msg=inferred type changes:silent", + "-Wconf:msg=case companions no longer extend FunctionN:silent", + "-Wconf:msg=access modifiers for:silent", + "-Wconf:msg=found in a package prefix of the required type:silent" ) def scalacPluginIvyDeps = diff --git a/integration/feature/output-directory/src/OutputDirectoryLockTests.scala b/integration/feature/output-directory/src/OutputDirectoryLockTests.scala index 13799e273aa..a8d6e6532ac 100644 --- a/integration/feature/output-directory/src/OutputDirectoryLockTests.scala +++ b/integration/feature/output-directory/src/OutputDirectoryLockTests.scala @@ -11,7 +11,7 @@ import scala.concurrent.{Await, ExecutionContext, Future} object OutputDirectoryLockTests extends UtestIntegrationTestSuite { private val pool = Executors.newCachedThreadPool() - private implicit val ec = ExecutionContext.fromExecutorService(pool) + private implicit val ec: ExecutionContext = ExecutionContext.fromExecutorService(pool) override def utestAfterAll(): Unit = { pool.shutdown() diff --git a/main/eval/test/src/mill/eval/ModuleTests.scala b/main/eval/test/src/mill/eval/ModuleTests.scala index 72750f5e081..f9160143c0c 100644 --- a/main/eval/test/src/mill/eval/ModuleTests.scala +++ b/main/eval/test/src/mill/eval/ModuleTests.scala @@ -9,7 +9,7 @@ import mill.define.Discover import utest._ object TestExternalModule extends mill.define.ExternalModule with mill.define.TaskModule { - def defaultCommandName = "x" + def defaultCommandName() = "x" def x = Task { 13 } object inner extends mill.Module { def y = Task { 17 } diff --git a/runner/src/mill/runner/MillBuildRootModule.scala b/runner/src/mill/runner/MillBuildRootModule.scala index 10ae284a0af..7e1676849f0 100644 --- a/runner/src/mill/runner/MillBuildRootModule.scala +++ b/runner/src/mill/runner/MillBuildRootModule.scala @@ -226,7 +226,7 @@ abstract class MillBuildRootModule()(implicit ) } - override def bindDependency: Task[Dep => BoundDep] = Task.Anon { dep: Dep => + override def bindDependency: Task[Dep => BoundDep] = Task.Anon { (dep: Dep) => super.bindDependency().apply(dep).exclude(resolveDepsExclusions(): _*) } diff --git a/scalalib/src/mill/scalalib/CoursierModule.scala b/scalalib/src/mill/scalalib/CoursierModule.scala index 4594916e4a0..a952acb62eb 100644 --- a/scalalib/src/mill/scalalib/CoursierModule.scala +++ b/scalalib/src/mill/scalalib/CoursierModule.scala @@ -23,7 +23,7 @@ trait CoursierModule extends mill.Module { * Bind a dependency ([[Dep]]) to the actual module contetxt (e.g. the scala version and the platform suffix) * @return The [[BoundDep]] */ - def bindDependency: Task[Dep => BoundDep] = Task.Anon { dep: Dep => + def bindDependency: Task[Dep => BoundDep] = Task.Anon { (dep: Dep) => BoundDep((resolveCoursierDependency(): @nowarn).apply(dep), dep.force) } @@ -80,7 +80,7 @@ trait CoursierModule extends mill.Module { * Map dependencies before resolving them. * Override this to customize the set of dependencies. */ - def mapDependencies: Task[Dependency => Dependency] = Task.Anon { d: Dependency => d } + def mapDependencies: Task[Dependency => Dependency] = Task.Anon { (d: Dependency) => d } /** * The repositories used to resolved dependencies with [[resolveDeps()]]. diff --git a/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala b/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala index 5b7c373992a..f8bb3ccdea5 100644 --- a/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala +++ b/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala @@ -144,7 +144,7 @@ class ZincWorkerImpl( compilerClasspath, scalacPluginClasspath, Seq() - ) { compilers: Compilers => + ) { (compilers: Compilers) => if (ZincWorkerUtil.isDotty(scalaVersion) || ZincWorkerUtil.isScala3Milestone(scalaVersion)) { // dotty 0.x and scala 3 milestones use the dotty-doc tool val dottydocClass = @@ -388,7 +388,7 @@ class ZincWorkerImpl( compilerClasspath = compilerClasspath, scalacPluginClasspath = scalacPluginClasspath, javacOptions = javacOptions - ) { compilers: Compilers => + ) { (compilers: Compilers) => compileInternal( upstreamCompileOutput = upstreamCompileOutput, sources = sources,