From 52c1bf2662eb288cbd55eb072a5de22d46647bfd Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 29 Jun 2023 09:51:07 +0200 Subject: [PATCH 1/2] Revert "Create legacy Scala 2/3 stdlib TASTy" This reverts commit 2faf77bf23569bef3dfd763601d9a9718526ef1a. --- build.sbt | 1 - project/Build.scala | 81 ++++++--------------------------------------- 2 files changed, 10 insertions(+), 72 deletions(-) diff --git a/build.sbt b/build.sbt index 28eedd0e38d7..80a36739d5e8 100644 --- a/build.sbt +++ b/build.sbt @@ -14,7 +14,6 @@ val `scala3-language-server` = Build.`scala3-language-server` 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-legacy` = Build.`stdlib-bootstrapped-legacy` val `stdlib-bootstrapped` = Build.`stdlib-bootstrapped` val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests` val `tasty-core` = Build.`tasty-core` diff --git a/project/Build.scala b/project/Build.scala index b47c7202933a..3638ca7fef51 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -926,59 +926,6 @@ object Build { javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value ) - /** Version of stdlib-bootstrapped that compiles both Scala 2 and Scala 3 libraries - * This is only used as a temporary solution until the docs can be generated using - * stdlib-bootstrapped and scala3-library-bootstrapped. - */ - lazy val `stdlib-bootstrapped-legacy` = project.in(file("stdlib-bootstrapped-legacy")). - withCommonSettings(Bootstrapped). - dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). - settings(commonBootstrappedSettings). - settings(stdlibBootstrappedCommonSettings). - settings( - scalacOptions -= "-Yscala2-stdlib", - 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, - mimaCheckDirection := "none", - ) - /** Scala 2 library compiled by dotty using the latest published sources of the library. * * This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library. @@ -987,15 +934,7 @@ object Build { withCommonSettings(Bootstrapped). dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). settings(commonBootstrappedSettings). - settings(stdlibBootstrappedCommonSettings). settings( - Compile / scalacOptions ++= { - Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString) - }, - ) - - lazy val stdlibBootstrappedCommonSettings = - Seq( moduleName := "scala-library", javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value, Compile / scalacOptions ++= { @@ -2019,7 +1958,7 @@ object ScaladocConfigs { def defaultSourceLinks(version: String = dottyNonBootstrappedVersion, refVersion: String = dottyVersion) = Def.task { def stdLibVersion = stdlibVersion(NonBootstrapped) - def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$v/src_managed/main/$s-library-src" + def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src" SourceLinks( List( scalaSrcLink(stdLibVersion, srcManaged(version, "scala") + "="), @@ -2107,7 +2046,7 @@ object ScaladocConfigs { lazy val Scala3 = Def.task { val dottyJars: Seq[java.io.File] = Seq( - (`stdlib-bootstrapped-legacy`/Compile/products).value, + (`stdlib-bootstrapped`/Compile/products).value, (`scala3-interfaces`/Compile/products).value, (`tasty-core-bootstrapped`/Compile/products).value, ).flatten @@ -2115,13 +2054,13 @@ object ScaladocConfigs { val roots = dottyJars.map(_.getAbsolutePath) val managedSources = - (`stdlib-bootstrapped-legacy`/Compile/sourceManaged).value / "scala-library-src" + (`stdlib-bootstrapped`/Compile/sourceManaged).value / "scala-library-src" val projectRoot = (ThisBuild/baseDirectory).value.toPath val stdLibRoot = projectRoot.relativize(managedSources.toPath.normalize()) val docRootFile = stdLibRoot.resolve("rootdoc.txt") val dottyManagesSources = - (`stdlib-bootstrapped-legacy`/Compile/sourceManaged).value / "dotty-library-src" + (`stdlib-bootstrapped`/Compile/sourceManaged).value / "dotty-library-src" val tastyCoreSources = projectRoot.relativize((`tasty-core-bootstrapped`/Compile/scalaSource).value.toPath().normalize()) @@ -2154,19 +2093,19 @@ object ScaladocConfigs { .add(ProjectVersion(version)) .add(SnippetCompiler( List( - s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src/scala/quoted=compile", - s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src/scala/compiletime=compile" + s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src/scala/quoted=compile", + s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src/scala/compiletime=compile" ) )) .add(CommentSyntax(List( - s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src=markdown", - s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src=wiki", + s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src=markdown", + s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src=wiki", "wiki" ))) - .add(DocRootContent(s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src/rootdoc.txt")) + .add(DocRootContent(s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src/rootdoc.txt")) .withTargets( Seq( - s"out/bootstrap/stdlib-bootstrapped-legacy/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes", + s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes", s"tmp/interfaces/target/classes", s"out/bootstrap/tasty-core-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes" ) From d7f769492664481297a825cc9037c093ad3483a4 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 29 Jun 2023 10:54:30 +0200 Subject: [PATCH 2/2] Generate docs for dotty library Fix #17964 --- library/src/scala/quoted/ToExpr.scala | 3 ++- project/Build.scala | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/library/src/scala/quoted/ToExpr.scala b/library/src/scala/quoted/ToExpr.scala index d7e55a5bc411..0e31c4590a26 100644 --- a/library/src/scala/quoted/ToExpr.scala +++ b/library/src/scala/quoted/ToExpr.scala @@ -422,7 +422,8 @@ object ToExpr { /** Default implementation of `ToExpr[BigDecimal using the default MathContext]` */ given BigDecimalToExpr: ToExpr[BigDecimal] with { def apply(x: BigDecimal)(using Quotes): Expr[BigDecimal] = - '{ BigDecimal(${Expr(x.toString)}) } + val bigDecimal: String = "" + x // workaround "method toString in class BigDecimal does not take parameters" in scaladoc/generateScalaDocumentation + '{ BigDecimal(${Expr(bigDecimal)}) } } /** Default implementation of `ToExpr[StringContext]` */ diff --git a/project/Build.scala b/project/Build.scala index 3638ca7fef51..ec2ae57bf4da 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1962,7 +1962,7 @@ object ScaladocConfigs { SourceLinks( List( scalaSrcLink(stdLibVersion, srcManaged(version, "scala") + "="), - dottySrcLink(refVersion, srcManaged(version, "dotty") + "=", "#library/src"), + dottySrcLink(refVersion, "library/src=", "#library/src"), dottySrcLink(refVersion), "docs=github://lampepfl/dotty/main#docs" ) @@ -2047,6 +2047,7 @@ object ScaladocConfigs { lazy val Scala3 = Def.task { val dottyJars: Seq[java.io.File] = Seq( (`stdlib-bootstrapped`/Compile/products).value, + (`scala3-library-bootstrapped`/Compile/products).value, (`scala3-interfaces`/Compile/products).value, (`tasty-core-bootstrapped`/Compile/products).value, ).flatten @@ -2060,7 +2061,7 @@ object ScaladocConfigs { val docRootFile = stdLibRoot.resolve("rootdoc.txt") val dottyManagesSources = - (`stdlib-bootstrapped`/Compile/sourceManaged).value / "dotty-library-src" + (`scala3-library-bootstrapped`/Compile/sourceDirectory).value val tastyCoreSources = projectRoot.relativize((`tasty-core-bootstrapped`/Compile/scalaSource).value.toPath().normalize()) @@ -2088,24 +2089,27 @@ object ScaladocConfigs { } def stableScala3(version: String) = Def.task { + val scalaLibrarySrc = s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed" + val dottyLibrarySrc = "library/src" Scala3.value .add(defaultSourceLinks(version + "-bin-SNAPSHOT-nonbootstrapped", version).value) .add(ProjectVersion(version)) .add(SnippetCompiler( List( - s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src/scala/quoted=compile", - s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src/scala/compiletime=compile" + s"$dottyLibrarySrc/scala/quoted=compile", + s"$dottyLibrarySrc/scala/compiletime=compile" ) )) .add(CommentSyntax(List( - s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src=markdown", - s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src=wiki", + s"$dottyLibrarySrc=markdown", + s"$scalaLibrarySrc=wiki", "wiki" ))) - .add(DocRootContent(s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src/rootdoc.txt")) + .add(DocRootContent(s"$scalaLibrarySrc/rootdoc.txt")) .withTargets( Seq( s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes", + s"out/bootstrap/scala3-library-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes", s"tmp/interfaces/target/classes", s"out/bootstrap/tasty-core-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes" )