Skip to content

Commit d8ec226

Browse files
authored
Include scala3-staging and scala3-tasty-inspector artifacts when the --with-compiler option is passed in Scala 3 (#2889)
1 parent 37c1b13 commit d8ec226

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ class SipScalaTests extends ScalaCliSuite with SbtTestHelper with MillTestHelper
608608
val localRepoPath = root / "local-repo"
609609
val sv = "3.4.1-RC1"
610610
val artifactNames =
611-
Seq("scala3-compiler_3") ++ (if (withBloop) Seq("scala3-sbt-bridge") else Nil)
611+
Seq("scala3-compiler_3", "scala3-staging_3", "scala3-tasty-inspector_3") ++
612+
(if (withBloop) Seq("scala3-sbt-bridge") else Nil)
612613
for { artifactName <- artifactNames } {
613614
val csRes = os.proc(
614615
TestUtil.cs,
@@ -692,6 +693,21 @@ class SipScalaTests extends ScalaCliSuite with SbtTestHelper with MillTestHelper
692693
}
693694
}
694695

696+
test("--with-compiler option includes scala3-staging & scala3-tasty-inspector artifacts") {
697+
TestInputs(os.rel / "example.sc" ->
698+
"""import scala.quoted.staging.Compiler
699+
|import scala.tasty.inspector.TastyInspector
700+
|""".stripMargin).fromRoot { root =>
701+
val res = os.proc(
702+
TestUtil.cli,
703+
"compile",
704+
"example.sc",
705+
"--with-compiler"
706+
).call(cwd = root)
707+
expect(res.exitCode == 0)
708+
}
709+
}
710+
695711
test(s"default Scala version override launcher option is respected by the json export") {
696712
val input = "printVersion.sc"
697713
val code = """println(s"Default version: ${scala.util.Properties.versionNumberString}")"""

modules/options/src/main/scala/scala/build/options/BuildOptions.scala

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,19 @@ final case class BuildOptions(
100100
}
101101

102102
private def scalaCompilerDependencies: Either[BuildException, Seq[AnyDependency]] = either {
103-
value(scalaParams).toSeq.flatMap { sp =>
104-
if (scalaOptions.addScalaCompiler.getOrElse(false))
105-
Seq(
106-
if (sp.scalaVersion.startsWith("3."))
107-
dep"org.scala-lang::scala3-compiler::${sp.scalaVersion}"
108-
else
109-
dep"org.scala-lang:scala-compiler:${sp.scalaVersion}"
110-
)
111-
else Nil
112-
}
103+
value(scalaParams)
104+
.map(_ -> scalaOptions.addScalaCompiler.getOrElse(false))
105+
.toSeq
106+
.flatMap {
107+
case (sp, true) if sp.scalaVersion.startsWith("3") =>
108+
Seq(
109+
dep"org.scala-lang::scala3-compiler::${sp.scalaVersion}",
110+
dep"org.scala-lang::scala3-staging::${sp.scalaVersion}",
111+
dep"org.scala-lang::scala3-tasty-inspector::${sp.scalaVersion}"
112+
)
113+
case (sp, true) => Seq(dep"org.scala-lang:scala-compiler:${sp.scalaVersion}")
114+
case _ => Nil
115+
}
113116
}
114117

115118
private def maybeJsDependencies: Either[BuildException, Seq[AnyDependency]] = either {

0 commit comments

Comments
 (0)