Skip to content

Commit b62635f

Browse files
committed
Don't force symbol completion when printing flags or annotations
1 parent 467fc6a commit b62635f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ object SymDenotations {
225225
ensureCompleted(); myAnnotations
226226
}
227227

228+
final def annotationsUNSAFE(using Context): List[Annotation] = myAnnotations
229+
228230
/** Update the annotations of this denotation */
229231
final def annotations_=(annots: List[Annotation]): Unit =
230232
myAnnotations = annots

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
786786
if mdef.hasType then Modifiers(mdef.symbol) else mdef.rawMods
787787

788788
private def Modifiers(sym: Symbol): Modifiers = untpd.Modifiers(
789-
sym.flags & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags),
789+
sym.flagsUNSAFE & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags),
790790
if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY,
791-
sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree))
791+
sym.annotationsUNSAFE.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree))
792792

793793
protected def dropAnnotForModText(sym: Symbol): Boolean = sym == defn.BodyAnnot
794794

@@ -985,13 +985,13 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
985985
else if (suppressKw) PrintableFlags(isType) &~ Private
986986
else PrintableFlags(isType)
987987
if (homogenizedView && mods.flags.isTypeFlags) flagMask &~= GivenOrImplicit // drop implicit/given from classes
988-
val rawFlags = if (sym.exists) sym.flags else mods.flags
988+
val rawFlags = if (sym.exists) sym.flagsUNSAFE else mods.flags
989989
if (rawFlags.is(Param)) flagMask = flagMask &~ Given &~ Erased
990990
val flags = rawFlags & flagMask
991991
var flagsText = toTextFlags(sym, flags)
992992
val annotTexts =
993993
if sym.exists then
994-
sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(toText)
994+
sym.annotationsUNSAFE.filterNot(ann => dropAnnotForModText(ann.symbol)).map(toText)
995995
else
996996
mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol)).map(annotText(NoSymbol, _))
997997
Text(annotTexts, " ") ~~ flagsText ~~ (Str(kw) provided !suppressKw)

0 commit comments

Comments
 (0)