Skip to content

Commit 74e6df9

Browse files
committed
Part 1 - fix compilation errors and stub macros
- use Scala 3.5.0 - add Scala 3 dialect to scalafmt.conf
1 parent 01b4d20 commit 74e6df9

File tree

58 files changed

+1162
-598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1162
-598
lines changed

.scalafmt.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ newlines.source = keep
2020

2121
project.git = true
2222

23-
runner.dialect = scala213
24-
23+
runner.dialect = scala3

bsp/src/mill/bsp/BspServerResult.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package mill.bsp
22

33
import mill.api.internal
4+
import scala.deriving.Mirror
45

56
@internal
67
sealed trait BspServerResult
@@ -28,4 +29,15 @@ object BspServerResult {
2829

2930
implicit val jsonify: upickle.default.ReadWriter[BspServerResult] =
3031
upickle.default.macroRW
32+
33+
// GENERATED CODE BY ci/scripts/manual_mirror_gen.sc - DO NOT EDIT
34+
private type SingletonMirrorProxy[T <: AnyRef & Singleton] = Mirror.SingletonProxy { val value: T }
35+
private def genSingletonMirror[T <: AnyRef & Singleton](ref: T): SingletonMirrorProxy[T] =
36+
new Mirror.SingletonProxy(ref).asInstanceOf[SingletonMirrorProxy[T]]
37+
private given Mirror_ReloadWorkspace: SingletonMirrorProxy[ReloadWorkspace.type] =
38+
genSingletonMirror(ReloadWorkspace)
39+
private given Mirror_Shutdown: SingletonMirrorProxy[Shutdown.type] =
40+
genSingletonMirror(Shutdown)
41+
private given Mirror_Failure: SingletonMirrorProxy[Failure.type] =
42+
genSingletonMirror(Failure)
3143
}

build.mill

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ object Deps {
5252
// The Scala version to use
5353
// When updating, run "Publish Bridges" Github Actions for the new version
5454
// and then add to it `bridgeScalaVersions`
55-
val scalaVersion = "2.13.14"
55+
val scalaVersion = "3.5.0"
56+
val scala2Version = "2.13.14"
5657
// Scoverage 1.x will not get releases for newer Scala versions
5758
val scalaVersionForScoverageWorker1 = "2.13.8"
5859
// The Scala 2.12.x version to use for some workers
@@ -67,14 +68,14 @@ object Deps {
6768

6869
object Scalajs_1 {
6970
val scalaJsVersion = "1.16.0"
70-
val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0"
71-
val scalajsEnvExoegoJsdomNodejs = ivy"net.exoego::scalajs-env-jsdom-nodejs:2.1.0"
72-
val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.4.0"
73-
val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0"
74-
val scalajsEnvSelenium = ivy"org.scala-js::scalajs-env-selenium:1.1.1"
75-
val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:${scalaJsVersion}"
76-
val scalajsLinker = ivy"org.scala-js::scalajs-linker:${scalaJsVersion}"
77-
val scalajsImportMap = ivy"com.armanbilge::scalajs-importmap:0.1.1"
71+
val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0".withDottyCompat(scalaVersion)
72+
val scalajsEnvExoegoJsdomNodejs = ivy"net.exoego::scalajs-env-jsdom-nodejs:2.1.0".withDottyCompat(scalaVersion)
73+
val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.4.0".withDottyCompat(scalaVersion)
74+
val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0".withDottyCompat(scalaVersion)
75+
val scalajsEnvSelenium = ivy"org.scala-js::scalajs-env-selenium:1.1.1".withDottyCompat(scalaVersion)
76+
val scalajsSbtTestAdapter = ivy"org.scala-js:scalajs-sbt-test-adapter_2.13:${scalaJsVersion}"
77+
val scalajsLinker = ivy"org.scala-js:scalajs-linker_2.13:${scalaJsVersion}"
78+
val scalajsImportMap = ivy"com.armanbilge::scalajs-importmap:0.1.1".withDottyCompat(scalaVersion)
7879
}
7980

8081
object Scalanative_0_5 {
@@ -101,9 +102,11 @@ object Deps {
101102
}
102103
object Play_2_7 extends Play {
103104
val playVersion = "2.7.9"
105+
override def scalaVersion: String = Deps.scala2Version
104106
}
105107
object Play_2_8 extends Play {
106108
val playVersion = "2.8.22"
109+
override def scalaVersion: String = Deps.scala2Version
107110
}
108111
object Play_2_9 extends Play {
109112
val playVersion = "2.9.5"
@@ -117,9 +120,9 @@ object Deps {
117120
val acyclic = ivy"com.lihaoyi:::acyclic:0.3.12"
118121
val ammoniteVersion = "3.0.0-M2-15-9bed9700"
119122
val asmTree = ivy"org.ow2.asm:asm-tree:9.7"
120-
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5"
123+
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5".withDottyCompat(scalaVersion)
121124

122-
val coursier = ivy"io.get-coursier::coursier:2.1.13"
125+
val coursier = ivy"io.get-coursier::coursier:2.1.13".withDottyCompat(scalaVersion)
123126
val coursierInterface = ivy"io.get-coursier:interface:1.0.19"
124127

125128
val cask = ivy"com.lihaoyi::cask:0.9.4"
@@ -159,8 +162,11 @@ object Deps {
159162
// can't use newer versions, as these need higher Java versions
160163
val testng = ivy"org.testng:testng:7.5.1"
161164
val sbtTestInterface = ivy"org.scala-sbt:test-interface:1.0"
162-
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:${scalaVersion}"
163-
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.8.3"
165+
def scalaCompiler(scalaVersion: String) = {
166+
if (scalaVersion.startsWith("3.")) ivy"org.scala-lang:scala3-compiler_3:${scalaVersion}"
167+
else ivy"org.scala-lang:scala-compiler:${scalaVersion}"
168+
}
169+
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.8.3".withDottyCompat(scalaVersion)
164170
def scalap(scalaVersion: String) = ivy"org.scala-lang:scalap:${scalaVersion}"
165171
def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:${scalaVersion}"
166172
val scalacScoveragePlugin = ivy"org.scoverage:::scalac-scoverage-plugin:1.4.11"
@@ -179,11 +185,11 @@ object Deps {
179185
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.1"
180186
val upickle = ivy"com.lihaoyi::upickle:3.3.1"
181187
val windowsAnsi = ivy"io.github.alexarchambault.windows-ansi:windows-ansi:0.0.5"
182-
val zinc = ivy"org.scala-sbt::zinc:1.10.2"
188+
val zinc = ivy"org.scala-sbt::zinc:1.10.2".withDottyCompat(scalaVersion)
183189
// keep in sync with doc/antora/antory.yml
184190
val bsp4j = ivy"ch.epfl.scala:bsp4j:2.2.0-M2"
185191
val fansi = ivy"com.lihaoyi::fansi:0.5.0"
186-
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.14.0"
192+
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.14.0".withDottyCompat(scalaVersion)
187193
val requests = ivy"com.lihaoyi::requests:0.9.0"
188194
val logback = ivy"ch.qos.logback:logback-classic:1.5.7"
189195
val sonatypeCentralClient = ivy"com.lumidion::sonatype-central-client-requests:0.3.0"
@@ -243,7 +249,7 @@ def millBinPlatform: T[String] = T {
243249
def baseDir = build.millSourcePath
244250

245251
val essentialBridgeScalaVersions =
246-
Seq(Deps.scalaVersion, Deps.scalaVersionForScoverageWorker1, Deps.workerScalaVersion212)
252+
Seq(Deps.scalaVersion, Deps.scala2Version, Deps.scalaVersionForScoverageWorker1, Deps.workerScalaVersion212)
247253
// published compiler bridges
248254
val bridgeScalaVersions = Seq(
249255
// Our version of Zinc doesn't work with Scala 2.12.0 and 2.12.4 compiler
@@ -380,20 +386,23 @@ trait MillPublishJavaModule extends MillJavaModule with PublishModule {
380386
*/
381387
trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModule { outer =>
382388
def scalaVersion = Deps.scalaVersion
389+
def scalapVersion = T { Deps.scala2Version }
383390
def scalafixScalaBinaryVersion = ZincWorkerUtil.scalaBinaryVersion(scalaVersion())
384391
def semanticDbVersion = Deps.semanticDBscala.version
385392
def scalacOptions =
386393
super.scalacOptions() ++ Seq(
387394
"-deprecation",
388-
"-P:acyclic:force",
389395
"-feature",
390396
"-Xlint:unused",
391397
"-Xlint:adapted-args"
398+
) ++ (
399+
if (scalaVersion().startsWith("3.")) Seq.empty
400+
else Seq("-P:acyclic:force")
392401
)
393402

394403
def scalacPluginIvyDeps =
395404
super.scalacPluginIvyDeps() ++
396-
Agg(Deps.acyclic) ++
405+
Agg.when(!scalaVersion().startsWith("3."))(Deps.acyclic) ++
397406
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefsPlugin)
398407

399408
def mandatoryIvyDeps =
@@ -413,7 +422,8 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
413422
trait MillBaseTestsModule extends TestModule {
414423
def forkArgs = T {
415424
Seq(
416-
s"-DMILL_SCALA_2_13_VERSION=${Deps.scalaVersion}",
425+
s"-DMILL_SCALA_3_NEXT_VERSION=${Deps.scalaVersion}",
426+
s"-DMILL_SCALA_2_13_VERSION=${Deps.scala2Version}",
417427
s"-DMILL_SCALA_2_12_VERSION=${Deps.workerScalaVersion212}",
418428
s"-DTEST_SCALA_2_13_VERSION=${Deps.testScala213Version}",
419429
s"-DTEST_SCALA_2_13_VERSION_FOR_SCALANATIVE_4_2=${Deps.testScala213VersionForScalaNative42}",
@@ -556,7 +566,9 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
556566
def ivyDeps = Agg(
557567
ivy"org.scala-sbt:compiler-interface:${Deps.zinc.version}",
558568
ivy"org.scala-sbt:util-interface:${Deps.zinc.version}",
559-
ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
569+
) ++ Agg(
570+
if (crossScalaVersion.startsWith("3.")) ivy"org.scala-lang::scala3-compiler:${crossScalaVersion}"
571+
else ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
560572
)
561573

562574
def resources = T.sources {
@@ -565,7 +577,8 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
565577
}
566578

567579
def compilerBridgeIvyDeps: T[Agg[Dep]] = Agg(
568-
ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.version}".exclude("*" -> "*")
580+
(if (crossScalaVersion.startsWith("3.")) ivy"org.scala-lang:scala3-sbt-bridge:${crossScalaVersion}"
581+
else ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.version}").exclude("*" -> "*")
569582
)
570583

571584
def compilerBridgeSourceJars: T[Agg[PathRef]] = T {
@@ -726,19 +739,19 @@ object dist0 extends MillPublishJavaModule {
726739

727740
def testTransitiveDeps = build.runner.testTransitiveDeps() ++ Seq(
728741
build.main.graphviz.testDep(),
729-
build.runner.linenumbers.testDep(),
742+
// build.runner.linenumbers.testDep(),
730743
build.scalalib.backgroundwrapper.testDep(),
731744
build.contrib.bloop.testDep(),
732745
build.contrib.buildinfo.testDep(),
733-
build.contrib.scoverage.testDep(),
734-
build.contrib.scoverage.worker2.testDep(),
735-
build.contrib.jmh.testDep(),
736-
build.contrib.playlib.testDep(),
737-
build.contrib.playlib.worker("2.8").testDep(),
738-
build.contrib.errorprone.testDep(),
739-
build.contrib.checkstyle.testDep(),
740-
build.bsp.worker.testDep(),
741-
build.testkit.testDep()
746+
// build.contrib.scoverage.testDep(),
747+
// build.contrib.scoverage.worker2.testDep(),
748+
// build.contrib.jmh.testDep(),
749+
// build.contrib.playlib.testDep(),
750+
// build.contrib.playlib.worker("2.8").testDep(),
751+
// build.contrib.errorprone.testDep(),
752+
// build.contrib.checkstyle.testDep(),
753+
// build.bsp.worker.testDep(),
754+
// build.testkit.testDep()
742755
)
743756
}
744757

@@ -1011,14 +1024,14 @@ def validate(): Command[Unit] = {
10111024
}
10121025

10131026
val dummyDeps: Seq[Dep] = Seq(
1014-
Deps.DocDeps.millScip,
1027+
// Deps.DocDeps.millScip,
10151028
Deps.semanticDbJava,
1016-
Deps.semanticDBscala,
1029+
// Deps.semanticDBscala,
10171030
Deps.TestDeps.scalaTest,
10181031
Deps.TestDeps.zioTest,
1019-
Deps.acyclic,
1020-
Deps.scalacScoverage2Plugin,
1021-
ivy"com.lihaoyi:::ammonite:${Deps.ammoniteVersion}"
1032+
// Deps.acyclic,
1033+
// Deps.scalacScoverage2Plugin,
1034+
// ivy"com.lihaoyi:::ammonite:${Deps.ammoniteVersion}"
10221035
) ++ Deps.transitiveDeps ++ Deps.RuntimeDeps.all
10231036

10241037
implicit object DepSegment extends Cross.ToSegments[Dep]({ dep =>

ci/scripts/manual_mirror_gen.sc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//> using scala 3.5.0-RC6
2+
//> using options -language:experimental.namedTuples
3+
4+
val cls = (
5+
name = "JarManifest",
6+
values = List(),
7+
sum = false,
8+
hasApply = true,
9+
modifier = "private",
10+
ctor = List(
11+
"main" -> "Map[String, String]",
12+
"groups" -> "Map[String, Map[String, String]]",
13+
// "headless" -> "Boolean"
14+
// "dest" -> "mill.PathRef",
15+
)
16+
)
17+
18+
val padding = 2
19+
20+
// derived values
21+
22+
val (ctorNames, ctorTypes) = (cls.ctor: List[(String, String)]).unzip
23+
24+
def asTuple[T](elems: List[T]): String =
25+
if elems.isEmpty then "EmptyTuple"
26+
else if elems.sizeIs == 1 then s"${elems.head} *: EmptyTuple"
27+
else elems.mkString("(", ", ", ")")
28+
29+
def factory(args: List[String]) =
30+
val list = args.mkString(",")
31+
if cls.hasApply then
32+
s"""${cls.name}.apply($list)"""
33+
else
34+
s"""new ${cls.name}($list)"""
35+
36+
val mod = if cls.modifier.isEmpty() then "" else s"${cls.modifier} "
37+
38+
val typedValues = cls.values: List[String]
39+
40+
val str = (
41+
if typedValues.nonEmpty then
42+
// singleton
43+
s"""// GENERATED CODE BY ${scriptPath} - DO NOT EDIT
44+
private type SingletonMirrorProxy[T <: AnyRef & Singleton] = Mirror.SingletonProxy { val value: T }
45+
private def genSingletonMirror[T <: AnyRef & Singleton](ref: T): SingletonMirrorProxy[T] =
46+
new Mirror.SingletonProxy(ref).asInstanceOf[SingletonMirrorProxy[T]]
47+
${typedValues.map{ v =>
48+
s"""${mod}given Mirror_${v.replace(".", "_")}: SingletonMirrorProxy[${v}.type] =
49+
genSingletonMirror(${v})"""}.mkString("\n")}"""
50+
else if cls.sum then
51+
// enum
52+
s"""// GENERATED CODE BY ${scriptPath} - DO NOT EDIT
53+
${mod}given Mirror_${cls.name.replace(".", "_")}: Mirror.Sum with {
54+
final type MirroredMonoType = ${cls.name}
55+
final type MirroredType = ${cls.name}
56+
final type MirroredElemTypes = ${asTuple(ctorTypes)}
57+
final type MirroredElemLabels = ${asTuple(ctorNames.map(s => s"$"$s$""))}
58+
59+
final def ordinal(p: ${cls.name}): Int = {
60+
p match {
61+
${ctorTypes.zipWithIndex.map{ (tpe, i) =>
62+
s"case _: $tpe => $i"
63+
}.mkString("", "\n ","")}
64+
}
65+
}
66+
}"""
67+
else
68+
s"""// GENERATED CODE BY ${scriptPath} - DO NOT EDIT
69+
${mod}given Mirror_${cls.name.replace(".", "_")}: Mirror.Product with {
70+
final type MirroredMonoType = ${cls.name}
71+
final type MirroredType = ${cls.name}
72+
final type MirroredElemTypes = ${asTuple(ctorTypes)}
73+
final type MirroredElemLabels = ${asTuple(ctorNames.map(s => s"$"$s$""))}
74+
75+
final def fromProduct(p: scala.Product): ${cls.name} = {
76+
${ctorTypes.zipWithIndex.map{ (tpe, i) =>
77+
s"val _${i + 1}: $tpe = p.productElement($i).asInstanceOf[$tpe]"
78+
}.mkString("", "\n ","\n")}
79+
${factory(ctorTypes.zipWithIndex.map{ (_, i) => s"_${i + 1}"})}
80+
}
81+
}"""
82+
)
83+
84+
println(str.linesIterator.map(s => s"${" " * padding}$s").mkString("\n"))

contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ trait BuildInfo extends JavaModule {
3535
*/
3636
def buildInfoMembers: T[Seq[BuildInfo.Value]] = Seq.empty[BuildInfo.Value]
3737

38-
def resources: T[Seq[PathRef]] =
38+
// TODO: remove override when mill-moduledefs is ported to Scala 3
39+
override def resources: T[Seq[PathRef]] =
3940
if (buildInfoStaticCompiled) super.resources
4041
else Task.Sources { super.resources() ++ Seq(buildInfoResources()) }
4142

contrib/package.mill

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,10 @@ object `package` extends RootModule {
149149
def compileIvyDeps = T {
150150
Agg(
151151
// compile-time only, need to provide the correct scoverage version at runtime
152-
build.Deps.scalacScoverage2Plugin,
153152
build.Deps.scalacScoverage2Reporter,
154153
build.Deps.scalacScoverage2Domain,
155154
build.Deps.scalacScoverage2Serializer
156-
)
155+
) ++ Agg.when(!scalaVersion().startsWith("3."))(build.Deps.scalacScoverage2Plugin)
157156
}
158157
}
159158
}

contrib/versionfile/src/mill/contrib/versionfile/Version.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ sealed trait Version {
3434
}
3535

3636
this match {
37-
case release: Release => Release.tupled(segments)
38-
case snapshot: Snapshot => Snapshot.tupled(segments)
37+
case release: Release => Release.apply.tupled(segments)
38+
case snapshot: Snapshot => Snapshot.apply.tupled(segments)
3939
}
4040
}
4141
}

main/api/src/mill/api/AggWrapper.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ private[mill] sealed class AggWrapper(strictUniqueness: Boolean) {
3333
def map[T](f: V => T): Agg[T]
3434
def filter(f: V => Boolean): Agg[V]
3535

36-
def collect[T](f: PartialFunction[V, T]): Agg[T]
37-
def zipWithIndex: Agg[(V, Int)]
36+
override def collect[T](f: PartialFunction[V, T]): Agg[T] = super.collect(f)
37+
override def zipWithIndex: Agg[(V, Int)] = super.zipWithIndex
3838
def reverse: Agg[V]
3939
def zip[T](other: Agg[T]): Agg[(V, T)]
40-
def ++[T >: V](other: IterableOnce[T]): Agg[T]
40+
// def ++[T >: V](other: IterableOnce[T]): Agg[T] // error overriding final method ++ in trait IterableOps
4141
def length: Int
4242
def isEmpty: Boolean
4343
def foreach[U](f: V => U): Unit

main/api/src/mill/api/Ctx.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.language.implicitConversions
77
* Provides access to various resources in the context of a currently execution Target.
88
*/
99
object Ctx {
10-
@compileTimeOnly("Target.ctx() / T.ctx() / T.* APIs can only be used with a T{...} block")
10+
// @compileTimeOnly("Target.ctx() / T.ctx() / T.* APIs can only be used with a T{...} block")
1111
@ImplicitStub
1212
implicit def taskCtx: Ctx = ???
1313

main/api/src/mill/api/JarManifest.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ object JarManifest {
6161
groups: Map[String, Map[String, String]] = Map.empty
6262
): JarManifest = new JarManifest(main, groups)
6363

64+
import scala.deriving.Mirror
65+
// GENERATED CODE BY ci/scripts/manual_mirror_gen.sc - DO NOT EDIT
66+
private given Mirror_JarManifest: Mirror.Product with {
67+
final type MirroredMonoType = JarManifest
68+
final type MirroredType = JarManifest
69+
final type MirroredElemTypes = (Map[String, String], Map[String, Map[String, String]])
70+
final type MirroredElemLabels = ("main", "groups")
71+
72+
final def fromProduct(p: scala.Product): JarManifest = {
73+
val _1: Map[String, String] = p.productElement(0).asInstanceOf[Map[String, String]]
74+
val _2: Map[String, Map[String, String]] = p.productElement(1).asInstanceOf[Map[String, Map[String, String]]]
75+
76+
JarManifest.apply(_1,_2)
77+
}
78+
}
79+
6480
implicit val jarManifestRW: ReadWriter[JarManifest] = upickle.default.macroRW
6581

6682
}

0 commit comments

Comments
 (0)