Skip to content

Use setting to enable Scala2 library TASTy in scala3-bootstrapped #18730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/test/dotty/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ object Properties {
/** scala-library jar */
def scalaLibrary: String = sys.props("dotty.tests.classes.scalaLibrary")

/** scala-library TASTy jar */
def scalaLibraryTasty: Option[String] = sys.props.get("dotty.tests.tasties.scalaLibrary")

/** scala-asm jar */
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")

Expand Down
6 changes: 4 additions & 2 deletions compiler/test/dotty/tools/vulpix/TestConfiguration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ object TestConfiguration {
"-Xverify-signatures"
)

val basicClasspath = mkClasspath(List(
val basicClasspath = mkClasspath(
Properties.scalaLibraryTasty.toList ::: List(
Properties.scalaLibrary,
Properties.dottyLibrary
))

val withCompilerClasspath = mkClasspath(List(
val withCompilerClasspath = mkClasspath(
Properties.scalaLibraryTasty.toList ::: List(
Properties.scalaLibrary,
Properties.scalaAsm,
Properties.jlineTerminal,
Expand Down
22 changes: 16 additions & 6 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ object Build {
// Run tests with filter through vulpix test suite
val testCompilation = inputKey[Unit]("runs integration test with the supplied filter")

// Use the TASTy jar from `scala2-library-tasty` in the classpath
// This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
//
// Enable in SBT with: set ThisBuild/Build.useScala2LibraryTasty := true
val useScala2LibraryTasty = settingKey[Boolean]("Use the TASTy jar from `scala2-library-tasty` in the classpath")

// Used to compile files similar to ./bin/scalac script
val scalac = inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath")

Expand Down Expand Up @@ -219,6 +225,8 @@ object Build {

outputStrategy := Some(StdoutOutput),

useScala2LibraryTasty := false,

// enable verbose exception messages for JUnit
(Test / testOptions) += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-s"),
)
Expand Down Expand Up @@ -633,7 +641,11 @@ object Build {
val externalDeps = externalCompilerClasspathTask.value
val jars = packageAll.value

Seq(
val scala2LibraryTasty =
if (useScala2LibraryTasty.value) Seq("-Ddotty.tests.tasties.scalaLibrary=" + jars("scala2-library-tasty"))
else Seq.empty

scala2LibraryTasty ++ Seq(
"-Ddotty.tests.dottyCompilerManagedSources=" + managedSrcDir,
"-Ddotty.tests.classes.dottyInterfaces=" + jars("scala3-interfaces"),
"-Ddotty.tests.classes.dottyLibrary=" + jars("scala3-library"),
Expand Down Expand Up @@ -729,11 +741,9 @@ object Build {
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
val decompile = args0.contains("-decompile")
val printTasty = args0.contains("-print-tasty")
val useScala2LibraryTasty = args0.contains("-Yscala2-library-tasty")
val debugFromTasty = args0.contains("-Ythrough-tasty")
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty"
&& arg != "-Yscala2-library-tasty")
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty")
val main =
if (decompile) "dotty.tools.dotc.decompiler.Main"
else if (printTasty) "dotty.tools.dotc.core.tasty.TastyPrinter"
Expand All @@ -742,10 +752,10 @@ object Build {

var extraClasspath =
scalaLibTastyOpt match {
case Some(scalaLibTasty) if useScala2LibraryTasty =>
case Some(scalaLibTasty) if useScala2LibraryTasty.value =>
Seq(scalaLibTasty, scalaLib, dottyLib)
case _ =>
if (useScala2LibraryTasty) log.error("-Yscala2-library-tasty can only be used with a bootstrapped compiler")
if (useScala2LibraryTasty.value) log.warn("useScala2LibraryTasty is ignored on non-bootstrapped compiler")
Seq(scalaLib, dottyLib)
}

Expand Down