Skip to content

Commit 8c14f5a

Browse files
committed
Fix documentation generation from tasty
When running scaladoc with `-from-tasty`, documentation generation for scala-library-bootstrapped failed with capture checking errors. Two issues were identified and fixed: 1. Capture checking was re-running on already capture-checked code from tasty, causing spurious errors. Now `ccEnabled` and `ccEnabledSomewhere` return false when `-from-tasty` is set. 2. The `-sourcepath` setting was causing source files to be loaded, which is unnecessary when compiling from tasty (doc comments are stored in tasty). The original comment said it was needed for `Definitions#init`, but that mechanism (ScalaShadowingPackageClass) was removed long ago.
1 parent 6462d7d commit 8c14f5a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,27 @@ object Feature:
140140
|| ctx.compilationUnit.knowsPureFuns
141141
|| ccEnabled
142142

143-
/** Is captureChecking enabled for this compilation unit? */
143+
/** Is captureChecking enabled for this compilation unit?
144+
* Disabled when compiling from tasty since capture checking was already performed.
145+
*/
144146
def ccEnabled(using Context) =
145-
enabledBySetting(captureChecking)
146-
|| ctx.originalCompilationUnit.needsCaptureChecking
147+
!ctx.settings.fromTasty.value
148+
&& (enabledBySetting(captureChecking)
149+
|| ctx.originalCompilationUnit.needsCaptureChecking)
147150

148151
/** Is pureFunctions enabled for any of the currently compiled compilation units? */
149152
def pureFunsEnabledSomewhere(using Context) =
150153
enabledBySetting(pureFunctions)
151154
|| ctx.run != null && ctx.run.nn.pureFunsImportEncountered
152155
|| ccEnabledSomewhere
153156

154-
/** Is captureChecking enabled for any of the currently compiled compilation units? */
157+
/** Is captureChecking enabled for any of the currently compiled compilation units?
158+
* Disabled when compiling from tasty since capture checking was already performed.
159+
*/
155160
def ccEnabledSomewhere(using Context) =
156-
if ctx.run != null then ctx.run.nn.ccEnabledSomewhere
157-
else enabledBySetting(captureChecking)
161+
!ctx.settings.fromTasty.value
162+
&& (if ctx.run != null then ctx.run.nn.ccEnabledSomewhere
163+
else enabledBySetting(captureChecking))
158164

159165
def sourceVersionSetting(using Context): SourceVersion =
160166
SourceVersion.valueOf(ctx.settings.source.value)

project/Build.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ object Build {
13121312
lazy val `scala-library-bootstrapped` = project.in(file("library"))
13131313
.enablePlugins(ScalaLibraryPlugin)
13141314
.settings(publishSettings)
1315-
.settings(disableDocSetting) // TODO now produces empty JAR to satisfy Sonatype, see https://github.com/scala/scala3/issues/24434
1315+
//.settings(disableDocSetting) // TODO now produces empty JAR to satisfy Sonatype, see https://github.com/scala/scala3/issues/24434
13161316
.settings(
13171317
name := "scala-library-bootstrapped",
13181318
moduleName := "scala-library",
@@ -1332,10 +1332,6 @@ object Build {
13321332
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
13331333
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
13341334
Compile / scalacOptions += "-Yno-stdlib-patches",
1335-
Compile / scalacOptions ++= Seq(
1336-
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
1337-
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
1338-
),
13391335
// Packaging configuration of the stdlib
13401336
Compile / packageBin / publishArtifact := true,
13411337
Compile / packageDoc / publishArtifact := true,

0 commit comments

Comments
 (0)