Skip to content

Commit 4d03e49

Browse files
committed
Use -Ystdlib to add Scala 2 lib TASTY to scalac (internal only)
This flag only works on the `scala3-bootstrapped/scalac` in the dotty project. It is intended for internal testing. Currently it is a bit expensive to compile the Scala 2 library TASTy. One reason in for this is that we need to use `-Ycheck:all` when compiling it to make sure that `-Yscala2-stdlib` is working properly. We only allow `scala3-bootstrapped/scalac` and not `scalac` to have this dependency for two reasons. First, we do want to be able to compile and run `scalac` command fast to reduce development testing time. Second, we do not have a stable enough version of the Scala 2 library TASTy yet. We also do not enable the Scala 2 library TASTy by default on `scala3-bootstrapped/scalac` because we still need this command to test against the current version of the library. Stability is also a concern for this version of the command.
1 parent 090710a commit 4d03e49

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

project/Build.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,22 +723,31 @@ object Build {
723723
val externalDeps = externalCompilerClasspathTask.value
724724
val jars = packageAll.value
725725
val scalaLib = findArtifactPath(externalDeps, "scala-library")
726+
val scalaLibTastyOpt = jars.get("stdlib-bootstrapped-tasty")
726727
val dottyLib = jars("scala3-library")
727728
val dottyCompiler = jars("scala3-compiler")
728729
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
729730
val decompile = args0.contains("-decompile")
730731
val printTasty = args0.contains("-print-tasty")
732+
val useScala2LibraryTasty = args0.contains("-Yscala2-library-tasty")
731733
val debugFromTasty = args0.contains("-Ythrough-tasty")
732734
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
733-
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty")
734-
735+
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty"
736+
&& arg != "-Yscala2-library-tasty")
735737
val main =
736738
if (decompile) "dotty.tools.dotc.decompiler.Main"
737739
else if (printTasty) "dotty.tools.dotc.core.tasty.TastyPrinter"
738740
else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug"
739741
else "dotty.tools.dotc.Main"
740742

741-
var extraClasspath = Seq(scalaLib, dottyLib)
743+
var extraClasspath =
744+
scalaLibTastyOpt match {
745+
case Some(scalaLibTasty) if useScala2LibraryTasty =>
746+
Seq(scalaLibTasty, scalaLib, dottyLib)
747+
case _ =>
748+
if (useScala2LibraryTasty) log.error("-Yscala2-library-tasty can only be used with a bootstrapped compiler")
749+
Seq(scalaLib, dottyLib)
750+
}
742751

743752
if (decompile && !args.contains("-classpath"))
744753
extraClasspath ++= Seq(".")
@@ -848,6 +857,7 @@ object Build {
848857
"scala3-staging" -> (LocalProject("scala3-staging") / Compile / packageBin).value.getAbsolutePath,
849858
"scala3-tasty-inspector" -> (LocalProject("scala3-tasty-inspector") / Compile / packageBin).value.getAbsolutePath,
850859
"tasty-core" -> (LocalProject("tasty-core-bootstrapped") / Compile / packageBin).value.getAbsolutePath,
860+
"stdlib-bootstrapped-tasty" -> (LocalProject("stdlib-bootstrapped-tasty") / Compile / packageBin).value.getAbsolutePath,
851861
)
852862
},
853863

0 commit comments

Comments
 (0)