Skip to content

Commit d3e1ae6

Browse files
Fix dottydoc tests
1 parent 44df2e8 commit d3e1ae6

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import dotc.core.Phases.Phase
88
import dotc.core.Mode
99
import dotc.{Compiler, CompilationUnit, Run}
1010
import dotc.typer.FrontEnd
11+
import dotc.typer.ImportInfo.withRootImports
1112

1213
import dotty.tools.dotc.fromtasty.{ReadTasty, TASTYRun}
1314
import dotty.tools.dotc.transform.CookComments
@@ -27,12 +28,14 @@ import dotty.tools.dotc.transform.CookComments
2728
class DocCompiler extends Compiler {
2829

2930
override def newRun(using Context): Run = {
30-
if (ctx.settings.fromTasty.value) {
31-
reset()
31+
reset()
32+
if ctx.settings.fromTasty.value then
3233
new TASTYRun(this, ctx.addMode(Mode.ReadPositions).addMode(Mode.ReadComments))
33-
}
3434
else
35-
super.newRun
35+
new Run(this, ctx) {
36+
override protected def rootContext(using Context): Context =
37+
super.rootContext.withRootImports
38+
}
3639
}
3740

3841
/** `DocFrontEnd` uses the Dotty `FrontEnd` without discarding the AnyVal

doc-tool/test/dotty/tools/dottydoc/DottyDocTest.scala

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ package dottydoc
33

44
import vulpix.TestConfiguration
55

6-
import dotc.Compiler
6+
import dotc.{Compiler, Run}
77
import dotc.core.Contexts.{ Context, ContextBase, FreshContext }
88
import dotc.core.Comments.{ ContextDoc, ContextDocstrings }
99
import dotc.util.SourceFile
1010
import dotc.core.Phases.Phase
11-
import dotty.tools.io.AbstractFile
1211
import dotc.typer.FrontEnd
13-
import dottydoc.core.{ DocASTPhase, ContextDottydoc }
14-
import model.Package
15-
import dotty.tools.dottydoc.util.syntax._
16-
import dotty.tools.io.AbstractFile
17-
import dotc.reporting.{ StoreReporter, MessageRendering }
12+
import dotc.typer.ImportInfo.withRootImports
1813
import dotc.interfaces.Diagnostic.ERROR
19-
import io.Directory
14+
import dotc.reporting.{ StoreReporter, MessageRendering }
15+
import util.syntax._
16+
import io.{AbstractFile, Directory}
17+
import core.{ DocASTPhase, ContextDottydoc }
18+
import model.Package
2019
import org.junit.Assert.fail
2120

2221
import java.io.{ BufferedWriter, OutputStreamWriter }
@@ -114,7 +113,15 @@ trait DottyDocTest extends MessageRendering {
114113
val ctx = freshCtx(out.toString :: Nil)
115114
ctx.setSetting(ctx.settings.outputDir, AbstractFile.getDirectory(out))
116115
}
117-
val dotc = new Compiler
116+
val dotc = new Compiler {
117+
override def newRun(using c: Context): Run =
118+
reset()
119+
new Run(this, c) {
120+
override protected def rootContext(using Context): Context =
121+
super.rootContext.withRootImports
122+
}
123+
}
124+
118125
val run = dotc.newRun(using dotcCtx)
119126
run.compileSources(sources)
120127
assert(!dotcCtx.reporter.hasErrors)

0 commit comments

Comments
 (0)