Skip to content

Commit 23cea59

Browse files
committed
Add DocArtifact flag
This flag is used to identify symbols that are introduced while cooking the comments (typically, these are the symbols created by the `@usecase` annotation). The flag is used to identify those symbols in the TreeChecker.
1 parent ba2eafc commit 23cea59

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ object Flags {
432432
/** A denotation that is valid in all run-ids */
433433
final val Permanent = commonFlag(62, "<permanent>")
434434

435+
/** A symbol introduced while cooking comments */
436+
final val DocArtifact = commonFlag(63, "<doc-artifact>")
437+
435438
// --------- Combined Flag Sets and Conjunctions ----------------------
436439

437440
/** Flags representing source modifiers */

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ class TreeChecker extends Phase with SymTransformer {
377377

378378
def isNonMagicalMethod(x: Symbol) =
379379
x.is(Method) &&
380+
!x.is(DocArtifact) &&
380381
!x.isCompanionMethod &&
381382
!x.isValueClassConvertMethod &&
382383
!(x.is(Macro) && ctx.phase.refChecked)

compiler/src/dotty/tools/dotc/typer/Docstrings.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ trait Docstrings { self: Typer =>
2323
val usecases = docbase.docstring(sym).map(_.usecases).getOrElse(Nil)
2424

2525
usecases.foreach { usecase =>
26-
enterSymbol(createSymbol(usecase.untpdCode))
26+
val createdSymbol = enterSymbol(createSymbol(usecase.untpdCode))
27+
createdSymbol.setFlag(Flags.DocArtifact)
2728

2829
typedStats(usecase.untpdCode :: Nil, owner) match {
2930
case List(df: tpd.DefDef) => usecase.tpdCode = df

0 commit comments

Comments
 (0)