Skip to content

Commit db39e36

Browse files
Use setting to enable Scala2 library TASTy in scala3-bootstrapped (#18730)
Enabling this setting will add the Scala2 library TASTy JAR from `scala2-library-tasty` to the Scala3 bootstrapped classpath. It can be used to compile using `scala3-bootstrapped/scalac` or run any tests in `scala3-bootstrapped`. Example usage: ``` sbt> set ThisBuild/Build.useScala2LibraryTasty := true sbt> scala3-bootstrapped/scalac sbt> scala3-bootstrapped/testCompilation ```
2 parents 5b416fa + bdc43ab commit db39e36

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

compiler/test/dotty/Properties.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ object Properties {
8282
/** scala-library jar */
8383
def scalaLibrary: String = sys.props("dotty.tests.classes.scalaLibrary")
8484

85+
/** scala-library TASTy jar */
86+
def scalaLibraryTasty: Option[String] = sys.props.get("dotty.tests.tasties.scalaLibrary")
87+
8588
/** scala-asm jar */
8689
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")
8790

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ object TestConfiguration {
2525
"-Xverify-signatures"
2626
)
2727

28-
val basicClasspath = mkClasspath(List(
28+
val basicClasspath = mkClasspath(
29+
Properties.scalaLibraryTasty.toList ::: List(
2930
Properties.scalaLibrary,
3031
Properties.dottyLibrary
3132
))
3233

33-
val withCompilerClasspath = mkClasspath(List(
34+
val withCompilerClasspath = mkClasspath(
35+
Properties.scalaLibraryTasty.toList ::: List(
3436
Properties.scalaLibrary,
3537
Properties.scalaAsm,
3638
Properties.jlineTerminal,

project/Build.scala

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ object Build {
173173
// Run tests with filter through vulpix test suite
174174
val testCompilation = inputKey[Unit]("runs integration test with the supplied filter")
175175

176+
// Use the TASTy jar from `scala2-library-tasty` in the classpath
177+
// This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
178+
//
179+
// Enable in SBT with: set ThisBuild/Build.useScala2LibraryTasty := true
180+
val useScala2LibraryTasty = settingKey[Boolean]("Use the TASTy jar from `scala2-library-tasty` in the classpath")
181+
176182
// Used to compile files similar to ./bin/scalac script
177183
val scalac = inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath")
178184

@@ -219,6 +225,8 @@ object Build {
219225

220226
outputStrategy := Some(StdoutOutput),
221227

228+
useScala2LibraryTasty := false,
229+
222230
// enable verbose exception messages for JUnit
223231
(Test / testOptions) += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-s"),
224232
)
@@ -633,7 +641,11 @@ object Build {
633641
val externalDeps = externalCompilerClasspathTask.value
634642
val jars = packageAll.value
635643

636-
Seq(
644+
val scala2LibraryTasty =
645+
if (useScala2LibraryTasty.value) Seq("-Ddotty.tests.tasties.scalaLibrary=" + jars("scala2-library-tasty"))
646+
else Seq.empty
647+
648+
scala2LibraryTasty ++ Seq(
637649
"-Ddotty.tests.dottyCompilerManagedSources=" + managedSrcDir,
638650
"-Ddotty.tests.classes.dottyInterfaces=" + jars("scala3-interfaces"),
639651
"-Ddotty.tests.classes.dottyLibrary=" + jars("scala3-library"),
@@ -729,11 +741,9 @@ object Build {
729741
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
730742
val decompile = args0.contains("-decompile")
731743
val printTasty = args0.contains("-print-tasty")
732-
val useScala2LibraryTasty = args0.contains("-Yscala2-library-tasty")
733744
val debugFromTasty = args0.contains("-Ythrough-tasty")
734745
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
735-
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty"
736-
&& arg != "-Yscala2-library-tasty")
746+
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty")
737747
val main =
738748
if (decompile) "dotty.tools.dotc.decompiler.Main"
739749
else if (printTasty) "dotty.tools.dotc.core.tasty.TastyPrinter"
@@ -742,10 +752,10 @@ object Build {
742752

743753
var extraClasspath =
744754
scalaLibTastyOpt match {
745-
case Some(scalaLibTasty) if useScala2LibraryTasty =>
755+
case Some(scalaLibTasty) if useScala2LibraryTasty.value =>
746756
Seq(scalaLibTasty, scalaLib, dottyLib)
747757
case _ =>
748-
if (useScala2LibraryTasty) log.error("-Yscala2-library-tasty can only be used with a bootstrapped compiler")
758+
if (useScala2LibraryTasty.value) log.warn("useScala2LibraryTasty is ignored on non-bootstrapped compiler")
749759
Seq(scalaLib, dottyLib)
750760
}
751761

0 commit comments

Comments
 (0)