Skip to content

Commit 10a3970

Browse files
committed
Typecheck usecases in fresh local scope
1 parent e1745ec commit 10a3970

File tree

6 files changed

+5
-7
lines changed

6 files changed

+5
-7
lines changed

dottydoc/src/dotty/tools/dottydoc/DottyDoc.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ abstract class DocDriver extends Driver {
5555
val summary = CompilerCommand.distill(args)(ctx)
5656

5757
ctx.setSettings(summary.sstate)
58-
ctx.setSetting(ctx.settings.Ydocrun, true)
58+
ctx.setSetting(ctx.settings.YkeepComments, true)
5959

6060
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(ctx)
6161
(fileNames, ctx)

dottydoc/test/BaseTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait DottyTest {
1717
import base.settings._
1818
val ctx = base.initialCtx.fresh
1919
ctx.setSetting(ctx.settings.language, List("Scala2"))
20-
ctx.setSetting(ctx.settings.Ydocrun, true)
20+
ctx.setSetting(ctx.settings.YkeepComments, true)
2121
base.initialize()(ctx)
2222
ctx
2323
}

src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ class ScalaSettings extends Settings.SettingGroup {
171171
val Ybuildmanagerdebug = BooleanSetting("-Ybuild-manager-debug", "Generate debug information for the Refined Build Manager compiler.")
172172
val Ycompletion = BooleanSetting("-Ycompletion-debug", "Trace all tab completion activity.")
173173
val Ydocdebug = BooleanSetting("-Ydoc-debug", "Trace all scaladoc activity.")
174-
val Ydocrun = BooleanSetting("-Ydoc-run", "Current run should be treated as a docrun, enables `@usecase` annotations in comments")
175174
val Yidedebug = BooleanSetting("-Yide-debug", "Generate, validate and output trees using the interactive compiler.")
176175
val Yinferdebug = BooleanSetting("-Yinfer-debug", "Trace type inference and implicit search.")
177176
val Yissuedebug = BooleanSetting("-Yissue-debug", "Print stack traces when a context issues an error.")

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ object SymDenotations {
15151515

15161516
/** Enter a symbol in given `scope` without potentially replacing the old copy. */
15171517
def enterNoReplace(sym: Symbol, scope: MutableScope)(implicit ctx: Context): Unit = {
1518-
lazy val isUsecase = ctx.settings.Ydocrun.value && sym.name.show.takeRight(4) == "$doc"
1518+
def isUsecase = sym.name.show.takeRight(4) == "$doc"
15191519

15201520
require((sym.denot.flagsUNSAFE is Private) || !(this is Frozen) || (scope ne this.unforcedDecls) || sym.hasAnnotation(defn.ScalaStaticAnnot) || isUsecase)
15211521
scope.enter(sym)

src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ object Scanners {
171171
}
172172

173173
class Scanner(source: SourceFile, override val startFrom: Offset = 0)(implicit ctx: Context) extends ScannerCommon(source)(ctx) {
174-
val keepComments = ctx.settings.YkeepComments.value || ctx.settings.Ydocrun.value
174+
val keepComments = ctx.settings.YkeepComments.value
175175

176176
/** All doc comments as encountered, each list contains doc comments from
177177
* the same block level. Starting with the deepest level and going upward

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
11931193
val dummy = localDummy(cls, impl)
11941194
val body1 = typedStats(impl.body, dummy)(inClassContext(self1.symbol))
11951195

1196-
if (ctx.settings.Ydocrun.value)
1197-
typedUsecases(body1.map(_.symbol), self1.symbol)
1196+
typedUsecases(body1.map(_.symbol), self1.symbol)(localContext(cdef, cls).setNewScope)
11981197

11991198
checkNoDoubleDefs(cls)
12001199
val impl1 = cpy.Template(impl)(constr1, parents1, self1, body1)

0 commit comments

Comments
 (0)