diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 39d2f3d84884..456aa70f2a17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -134,7 +134,7 @@ jobs: - name: Cmd Tests run: | - ./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-2_13-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test" + ./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test" ./project/scripts/cmdTests ./project/scripts/bootstrappedOnlyCmdTests @@ -253,7 +253,7 @@ jobs: - name: MiMa run: | - ./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; stdlib-2_13-bootstrapped/mimaReportBinaryIssues" + ./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; stdlib-bootstrapped/mimaReportBinaryIssues" community_build_a: runs-on: [self-hosted, Linux] @@ -488,7 +488,7 @@ jobs: - name: Test run: | - ./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-2_13-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test" + ./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test" ./project/scripts/cmdTests ./project/scripts/bootstrappedOnlyCmdTests diff --git a/build.sbt b/build.sbt index 715703633baf..80a36739d5e8 100644 --- a/build.sbt +++ b/build.sbt @@ -15,7 +15,6 @@ val `scala3-bench` = Build.`scala3-bench` val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped` val `scala3-bench-micro` = Build.`scala3-bench-micro` val `stdlib-bootstrapped` = Build.`stdlib-bootstrapped` -val `stdlib-2_13-bootstrapped` = Build.`stdlib-2_13-bootstrapped` val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests` val `tasty-core` = Build.`tasty-core` val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped` diff --git a/project/Build.scala b/project/Build.scala index 21b88969d597..8cc0163ca6a3 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -922,96 +922,30 @@ object Build { javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value ) - /** Scala library compiled by dotty using the latest published sources of the 2.13 library - * and the current Scala 3 library sources. - * - * This version of the library is not binary compatible with the Scala 2 compiled library. - * It compiles every file as Scala 3 sources. - */ - lazy val `stdlib-bootstrapped` = project.in(file("stdlib-bootstrapped")). - withCommonSettings(Bootstrapped). - dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). - settings(commonStdlibBootstrappedSettings). - settings( - Compile/scalacOptions ++= { - Seq( - "-sourcepath", - Seq( - (Compile/sourceManaged).value / "scala-library-src", - (Compile/sourceManaged).value / "dotty-library-src", - ).mkString(File.pathSeparator), - ) - }, - (Compile / sourceGenerators) += Def.task { - val s = streams.value - val cacheDir = s.cacheDirectory - val trgDir = (Compile / sourceManaged).value / "dotty-library-src" - - // NOTE `sourceDirectory` is used for actual copying, - // but `sources` are used as cache keys - val dottyLibSourceDirs = (`scala3-library-bootstrapped`/Compile/unmanagedSourceDirectories).value - def dottyLibSources = dottyLibSourceDirs.foldLeft(PathFinder.empty) { (pf, dir) => - if (!dir.exists) pf else pf +++ (dir ** "*.scala") +++ (dir ** "*.java") - } - - val cachedFun = FileFunction.cached( - cacheDir / s"copyDottyLibrarySrc", - FilesInfo.lastModified, - FilesInfo.exists, - ) { _ => - if (trgDir.exists) IO.delete(trgDir) - dottyLibSourceDirs.foreach { dir => - if (dir.exists) { - s.log.info(s"Copying scala3-library sources from $dir to $trgDir...") - IO.copyDirectory(dir, trgDir) - } - } - - ((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet - } - - cachedFun(dottyLibSources.get.toSet).toSeq - }.taskValue, - ) - /** Scala 2 library compiled by dotty using the latest published sources of the library. * - * This version of the library is not (yet) binary compatible with the Scala 2 compiled library. + * This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library. */ - lazy val `stdlib-2_13-bootstrapped` = project.in(file("stdlib-2_13-bootstrapped")). + lazy val `stdlib-bootstrapped` = project.in(file("stdlib-bootstrapped")). withCommonSettings(Bootstrapped). dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). - settings(commonStdlibBootstrappedSettings). + settings(commonBootstrappedSettings). settings( - scalacOptions += "-Yscala2-stdlib", - Compile / scalacOptions ++= { - Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString) - }, - // TODO package only TASTy files. - // We first need to check that a project can depend on a JAR that only contains TASTy files. - // Compile / exportJars := true, - // Compile / packageBin / mappings ~= { _.filter(_._2.endsWith(".tasty")) }, - mimaCheckDirection := "both", - mimaBackwardIssueFilters := MiMaFilters.StdlibBootstrappedBackwards, - mimaForwardIssueFilters := MiMaFilters.StdlibBootstrappedForward, - mimaPreviousArtifacts += "org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped), - mimaExcludeAnnotations ++= Seq( - "scala.annotation.experimental", - "scala.annotation.specialized", - "scala.annotation.unspecialized", - ), - ) - - lazy val commonStdlibBootstrappedSettings = - commonBootstrappedSettings ++ Seq( moduleName := "scala-library", javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value, Compile / doc / scalacOptions += "-Ydocument-synthetic-types", + scalacOptions += "-Yscala2-stdlib", scalacOptions -= "-Xfatal-warnings", ivyConfigurations += SourceDeps.hide, transitiveClassifiers := Seq("sources"), libraryDependencies += ("org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped) % "sourcedeps"), + (Test / managedClasspath) ~= { + _.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar") + }, + Compile / scalacOptions ++= { + Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString) + }, (Compile / sourceGenerators) += Def.task { val s = streams.value val cacheDir = s.cacheDirectory @@ -1051,10 +985,20 @@ object Build { val reference = (Compile/sourceManaged).value / "scala-library-src" files.filterNot(_.relativeTo(reference).exists(overwritenSources)) }, - (Test / managedClasspath) ~= { - _.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar") - }, - ) + // TODO package only TASTy files. + // We first need to check that a project can depend on a JAR that only contains TASTy files. + // Compile / exportJars := true, + // Compile / packageBin / mappings ~= { _.filter(_._2.endsWith(".tasty")) }, + mimaCheckDirection := "both", + mimaBackwardIssueFilters := MiMaFilters.StdlibBootstrappedBackwards, + mimaForwardIssueFilters := MiMaFilters.StdlibBootstrappedForward, + mimaPreviousArtifacts += "org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped), + mimaExcludeAnnotations ++= Seq( + "scala.annotation.experimental", + "scala.annotation.specialized", + "scala.annotation.unspecialized", + ), + ) /** Test the tasty generated by `stdlib-bootstrapped` * diff --git a/stdlib-2_13-bootstrapped/test/Main.scala b/stdlib-2_13-bootstrapped/test/Main.scala deleted file mode 100644 index 7f3bd33af8df..000000000000 --- a/stdlib-2_13-bootstrapped/test/Main.scala +++ /dev/null @@ -1,42 +0,0 @@ -package hello - -import scala.util.* -import scala.compiletime.testing.typeChecks - -enum Color: - case Red, Green, Blue - -object HelloWorld: - def main(args: Array[String]): Unit = { - println("hello 2.13 library bootstrapped") - println(Color.Red) - println(Color.Green) - println(Color.Blue) - - testScala2UnapplySignatures() - testScala2ObjectParents() - testScala2ProductMembers() - } - - def testScala2UnapplySignatures() = { - val _: Option[Int] = Some.unapply(Some(1)) - val _: Option[Int] = Right.unapply(Right(1)) - val _: Option[(Int, List[Int])] = ::.unapply(::(1, Nil)) - - val _: Option[Int] = Tuple1.unapply(Tuple1(1)) - val _: Option[(Int, Int)] = Tuple2.unapply((1, 2)) - val _: Option[(Int, Int, Int)] = Tuple3.unapply((1, 2, 3)) - } - - def testScala2ObjectParents() = { - assert(!typeChecks("Either: scala.deriving.Mirror.Sum")) - assert(!typeChecks("Either: scala.deriving.Mirror")) - } - def testScala2ProductMembers() = { - Some(1)._1 - Right(1)._1 - (1, 2)._1 - (1, 2)._2 - ::(1, Nil)._1 - ::(1, Nil)._2 - } diff --git a/stdlib-bootstrapped/test/Main.scala b/stdlib-bootstrapped/test/Main.scala index 1dad89eceffc..7f3bd33af8df 100644 --- a/stdlib-bootstrapped/test/Main.scala +++ b/stdlib-bootstrapped/test/Main.scala @@ -1,12 +1,42 @@ package hello +import scala.util.* +import scala.compiletime.testing.typeChecks + enum Color: case Red, Green, Blue object HelloWorld: def main(args: Array[String]): Unit = { - println("hello dotty.superbootstrapped!") + println("hello 2.13 library bootstrapped") println(Color.Red) println(Color.Green) println(Color.Blue) + + testScala2UnapplySignatures() + testScala2ObjectParents() + testScala2ProductMembers() + } + + def testScala2UnapplySignatures() = { + val _: Option[Int] = Some.unapply(Some(1)) + val _: Option[Int] = Right.unapply(Right(1)) + val _: Option[(Int, List[Int])] = ::.unapply(::(1, Nil)) + + val _: Option[Int] = Tuple1.unapply(Tuple1(1)) + val _: Option[(Int, Int)] = Tuple2.unapply((1, 2)) + val _: Option[(Int, Int, Int)] = Tuple3.unapply((1, 2, 3)) + } + + def testScala2ObjectParents() = { + assert(!typeChecks("Either: scala.deriving.Mirror.Sum")) + assert(!typeChecks("Either: scala.deriving.Mirror")) + } + def testScala2ProductMembers() = { + Some(1)._1 + Right(1)._1 + (1, 2)._1 + (1, 2)._2 + ::(1, Nil)._1 + ::(1, Nil)._2 }