File tree Expand file tree Collapse file tree 5 files changed +30
-11
lines changed
compiler/src/dotty/tools/dotc
doc-tool/src/dotty/tools/dottydoc/model Expand file tree Collapse file tree 5 files changed +30
-11
lines changed Original file line number Diff line number Diff line change @@ -108,11 +108,11 @@ object Flags {
108108
109109 /** The list of non-empty names of flags that are set in this FlagSet */
110110 def flagStrings (privateWithin : String ): Seq [String ] = {
111- val rawStrings = (2 to MaxFlag ).flatMap(flagString)
112- val scopeStr =
113- if ( this is Local ) " this "
114- else privateWithin
115- if (privateWithin != " " )
111+ var rawStrings = (2 to MaxFlag ).flatMap(flagString)
112+ if ( ! privateWithin.isEmpty && ! this .is( Protected ))
113+ rawStrings = rawStrings :+ " private "
114+ val scopeStr = if ( this .is( Local )) " this " else privateWithin
115+ if (scopeStr != " " )
116116 rawStrings.filter(_ != " <local>" ).map {
117117 case " private" => s " private[ $scopeStr] "
118118 case " protected" => s " protected[ $scopeStr] "
Original file line number Diff line number Diff line change @@ -403,9 +403,16 @@ class PlainPrinter(_ctx: Context) extends Printer {
403403 else " "
404404 }
405405
406+ protected def privateWithinString (sym : Symbol ): String =
407+ if (sym.exists && sym.privateWithin.exists)
408+ nameString(sym.privateWithin.name.stripModuleClassSuffix)
409+ else " "
410+
406411 /** String representation of symbol's flags */
407- protected def toTextFlags (sym : Symbol ): Text =
408- Text (sym.flagsUNSAFE.flagStrings(nameString(sym.privateWithin.name)) map stringToText, " " )
412+ protected def toTextFlags (sym : Symbol ): Text = toTextFlags(sym, sym.flagsUNSAFE)
413+
414+ protected def toTextFlags (sym : Symbol , flags : FlagSet ): Text =
415+ Text (flags.flagStrings(privateWithinString(sym)).map(flag => stringToText(keywordStr(flag))), " " )
409416
410417 /** String representation of symbol's variance or "" if not applicable */
411418 protected def varianceString (sym : Symbol ): String = varianceString(sym.variance)
Original file line number Diff line number Diff line change @@ -819,7 +819,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
819819 val rawFlags = if (sym.exists) sym.flags else mods.flags
820820 if (rawFlags.is(Param )) flagMask = flagMask &~ Given
821821 val flags = rawFlags & flagMask
822- val flagsText = if (flags.isEmpty) " " else keywordStr(flags.flagStrings(nameString( sym.privateWithin.name)).mkString( " " ) )
822+ val flagsText = toTextFlags( sym, flags )
823823 val annotations =
824824 if (sym.exists) sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree)
825825 else mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol))
@@ -896,7 +896,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
896896 else {
897897 var flags = sym.flagsUNSAFE
898898 if (flags is TypeParam ) flags = flags &~ Protected
899- Text (( flags & PrintableFlags (sym.isType)).flagStrings(nameString(sym.privateWithin.name)) map (flag => stringToText(keywordStr(flag))), " " )
899+ toTextFlags(sym, flags & PrintableFlags (sym.isType))
900900 }
901901
902902 override def toText (denot : Denotation ): Text = denot match {
Original file line number Diff line number Diff line change @@ -19,12 +19,15 @@ object factories {
1919
2020 type TypeTree = dotty.tools.dotc.ast.Trees .Tree [Type ]
2121
22- def flags (t : Tree )(implicit ctx : Context ): List [String ] =
22+ def flags (t : Tree )(implicit ctx : Context ): List [String ] = {
23+ val pw = t.symbol.privateWithin
24+ val pwStr = if (pw.exists) pw.name.show else " "
2325 (t.symbol.flags & (if (t.symbol.isType) TypeSourceModifierFlags else TermSourceModifierFlags ))
24- .flagStrings(t.symbol.privateWithin.name.show ).toList
26+ .flagStrings(pwStr ).toList
2527 .filter(_ != " <trait>" )
2628 .filter(_ != " interface" )
2729 .filter(_ != " case" )
30+ }
2831
2932 def path (sym : Symbol )(implicit ctx : Context ): List [String ] = {
3033 @ tailrec def go (sym : Symbol , acc : List [String ]): List [String ] =
Original file line number Diff line number Diff line change @@ -4,9 +4,18 @@ object Config {
44 inline val logging = false
55}
66
7+ class Logger {
8+ protected [this ] var a = 0
9+ protected [Logger ] var b = 0
10+ protected var c = 0
11+
12+ }
13+
714object Logger {
815
916 private var indent = 0
17+ private [this ] var a = 0
18+ private [Logger ] var b = 0
1019
1120 inline def log [T ](msg : String )(op : => T ): T =
1221 if (Config .logging) {
You can’t perform that action at this time.
0 commit comments