Skip to content

Commit

Permalink
More Scala 3 compatibility backports (#3724)
Browse files Browse the repository at this point in the history
Turned on `-Xsource:3` and fixed the most obvious syntax issues,
silenced the other less-trivial warnings
  • Loading branch information
lihaoyi authored Oct 12, 2024
1 parent 7da0265 commit 2831d97
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion main/eval/test/src/mill/eval/ModuleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion runner/src/mill/runner/MillBuildRootModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(): _*)
}

Expand Down
4 changes: 2 additions & 2 deletions scalalib/src/mill/scalalib/CoursierModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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()]].
Expand Down
4 changes: 2 additions & 2 deletions scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -388,7 +388,7 @@ class ZincWorkerImpl(
compilerClasspath = compilerClasspath,
scalacPluginClasspath = scalacPluginClasspath,
javacOptions = javacOptions
) { compilers: Compilers =>
) { (compilers: Compilers) =>
compileInternal(
upstreamCompileOutput = upstreamCompileOutput,
sources = sources,
Expand Down

0 comments on commit 2831d97

Please sign in to comment.