@@ -173,11 +173,23 @@ 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+ sealed trait Scala2Library
177+ // Use Scala 2 compiled library JAR
178+ object Scala2LibraryJar extends Scala2Library
176179 // Use the TASTy jar from `scala2-library-tasty` in the classpath
177180 // This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
178181 //
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" )
182+ object Scala2LibraryTasty extends Scala2Library
183+ // Use the TASTy jar from `scala2-library-cc-tasty` in the classpath
184+ // This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
185+ //
186+ object Scala2LibraryCCTasty extends Scala2Library
187+
188+ // Set in SBT with:
189+ // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryJar` (default)
190+ // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryTasty`
191+ // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty`
192+ val scala2Library = settingKey[Scala2Library ](" Choose which version of the Scala 2 library should be used" )
181193
182194 // Used to compile files similar to ./bin/scalac script
183195 val scalac = inputKey[Unit ](" run the compiler using the correct classpath, or the user supplied classpath" )
@@ -225,7 +237,7 @@ object Build {
225237
226238 outputStrategy := Some (StdoutOutput ),
227239
228- useScala2LibraryTasty := false ,
240+ scala2Library := Scala2LibraryJar ,
229241
230242 // enable verbose exception messages for JUnit
231243 (Test / testOptions) += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" , " -s" ),
@@ -645,12 +657,18 @@ object Build {
645657 val externalDeps = externalCompilerClasspathTask.value
646658 val jars = packageAll.value
647659
648- val scala2LibraryTasty = jars.get(" scala2-library-tasty" ) match {
649- case Some (scala2LibraryTastyJar) if useScala2LibraryTasty.value =>
650- Seq (" -Ddotty.tests.tasties.scalaLibrary=" + scala2LibraryTastyJar)
651- case _ =>
652- if (useScala2LibraryTasty.value) log.warn(" useScala2LibraryTasty is ignored on non-bootstrapped compiler" )
653- Seq .empty
660+ def libraryPathProperty (jarName : String ): Seq [String ] =
661+ jars.get(jarName) match {
662+ case Some (jar) =>
663+ Seq (s " -Ddotty.tests.tasties.scalaLibrary= $jar" )
664+ case None =>
665+ log.warn(" Scala 2 library TASTy is ignored on non-bootstrapped compiler" )
666+ Seq .empty
667+ }
668+ val scala2LibraryTasty = scala2Library.value match {
669+ case Scala2LibraryJar => Seq .empty
670+ case Scala2LibraryTasty => libraryPathProperty(" scala2-library-tasty" )
671+ case Scala2LibraryCCTasty => libraryPathProperty(" scala2-library-cc-tasty" )
654672 }
655673
656674 scala2LibraryTasty ++ Seq (
@@ -764,14 +782,24 @@ object Build {
764782 else if (debugFromTasty) " dotty.tools.dotc.fromtasty.Debug"
765783 else " dotty.tools.dotc.Main"
766784
767- var extraClasspath =
768- scalaLibTastyOpt match {
769- case Some (scalaLibTasty) if useScala2LibraryTasty.value =>
770- Seq (scalaLibTasty, scalaLib, dottyLib)
771- case _ =>
772- if (useScala2LibraryTasty.value) log.warn(" useScala2LibraryTasty is ignored on non-bootstrapped compiler" )
773- Seq (scalaLib, dottyLib)
774- }
785+ val scala2LibraryTasty = scala2Library.value match {
786+ case Scala2LibraryJar => Seq .empty
787+ case Scala2LibraryTasty =>
788+ jars.get(" scala2-library-tasty" ) match {
789+ case Some (jar) => Seq (jar)
790+ case None =>
791+ log.warn(" Scala2LibraryTasty is ignored on non-bootstrapped compiler" )
792+ Seq .empty
793+ }
794+ case Scala2LibraryCCTasty =>
795+ jars.get(" scala2-library-cc-tasty" ) match {
796+ case Some (jar) => Seq (jar)
797+ case None =>
798+ log.warn(" Scala2LibraryCCTasty is ignored on non-bootstrapped compiler" )
799+ Seq .empty
800+ }
801+ }
802+ var extraClasspath = scala2LibraryTasty ++ Seq (scalaLib, dottyLib)
775803
776804 if (decompile && ! args.contains(" -classpath" ))
777805 extraClasspath ++= Seq (" ." )
@@ -882,6 +910,7 @@ object Build {
882910 " scala3-tasty-inspector" -> (LocalProject (" scala3-tasty-inspector" ) / Compile / packageBin).value.getAbsolutePath,
883911 " tasty-core" -> (LocalProject (" tasty-core-bootstrapped" ) / Compile / packageBin).value.getAbsolutePath,
884912 " scala2-library-tasty" -> (LocalProject (" scala2-library-tasty" ) / Compile / packageBin).value.getAbsolutePath,
913+ " scala2-library-cc-tasty" -> (LocalProject (" scala2-library-cc-tasty" ) / Compile / packageBin).value.getAbsolutePath,
885914 )
886915 },
887916
@@ -1010,8 +1039,24 @@ object Build {
10101039 withCommonSettings(Bootstrapped ).
10111040 dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
10121041 settings(commonBootstrappedSettings).
1042+ settings(scala2LibraryBootstrappedSettings).
1043+ settings(moduleName := " scala2-library" )
1044+
1045+ /** Scala 2 library compiled by dotty using the latest published sources of the library.
1046+ *
1047+ * This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library.
1048+ */
1049+ lazy val `scala2-library-cc` = project.in(file(" scala2-library-cc" )).
1050+ withCommonSettings(Bootstrapped ).
1051+ dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
1052+ settings(commonBootstrappedSettings).
1053+ settings(scala2LibraryBootstrappedSettings).
10131054 settings(
1014- moduleName := " scala2-library" ,
1055+ moduleName := " scala2-library-cc" ,
1056+ scalacOptions += " -Ycheck:all" ,
1057+ )
1058+
1059+ lazy val scala2LibraryBootstrappedSettings = Seq (
10151060 javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
10161061 Compile / scalacOptions ++= {
10171062 Seq (" -sourcepath" , ((Compile / sourceManaged).value / " scala-library-src" ).toString)
@@ -1096,13 +1141,13 @@ object Build {
10961141 | - final val MinorVersion = $minorVersion
10971142 | - final val ExperimentalVersion = 0
10981143 | * Clean everything to generate a compiler with those new TASTy versions
1099- | * Run scala2-library-bootstrapped /tastyMiMaReportIssues
1144+ | * Run ${name.value} /tastyMiMaReportIssues
11001145 | """ .stripMargin)
11011146
11021147 }).value,
11031148 Compile / exportJars := true ,
11041149 artifactName := { (sv : ScalaVersion , module : ModuleID , artifact : Artifact ) =>
1105- " scala2-library -" + dottyVersion + " ." + artifact.extension
1150+ moduleName.value + " -" + dottyVersion + " ." + artifact.extension
11061151 },
11071152 run := {
11081153 val log = streams.value.log
@@ -1174,7 +1219,7 @@ object Build {
11741219 | """ .stripMargin)
11751220 }
11761221 }
1177- )
1222+ )
11781223
11791224 /** Packages the TASTy files of `scala2-library-bootstrapped` in a jar */
11801225 lazy val `scala2-library-tasty` = project.in(file(" scala2-library-tasty" )).
@@ -1187,6 +1232,17 @@ object Build {
11871232 },
11881233 )
11891234
1235+ /** Packages the TASTy files of `scala2-library-cc` in a jar */
1236+ lazy val `scala2-library-cc-tasty` = project.in(file(" scala2-library-cc-tasty" )).
1237+ withCommonSettings(Bootstrapped ).
1238+ settings(
1239+ exportJars := true ,
1240+ Compile / packageBin / mappings := {
1241+ (`scala2-library-cc` / Compile / packageBin / mappings).value
1242+ .filter(_._2.endsWith(" .tasty" ))
1243+ },
1244+ )
1245+
11901246 /** Test the tasty generated by `scala2-library-bootstrapped`
11911247 *
11921248 * The sources in src are compiled using TASTy from scala2-library-tasty but then run
0 commit comments