File tree 5 files changed +30
-11
lines changed
compiler/src/dotty/tools/dotc
doc-tool/src/dotty/tools/dottydoc/model
5 files changed +30
-11
lines changed Original file line number Diff line number Diff line change @@ -108,11 +108,11 @@ object Flags {
108
108
109
109
/** The list of non-empty names of flags that are set in this FlagSet */
110
110
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 != " " )
116
116
rawStrings.filter(_ != " <local>" ).map {
117
117
case " private" => s " private[ $scopeStr] "
118
118
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 {
403
403
else " "
404
404
}
405
405
406
+ protected def privateWithinString (sym : Symbol ): String =
407
+ if (sym.exists && sym.privateWithin.exists)
408
+ nameString(sym.privateWithin.name.stripModuleClassSuffix)
409
+ else " "
410
+
406
411
/** 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))), " " )
409
416
410
417
/** String representation of symbol's variance or "" if not applicable */
411
418
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) {
819
819
val rawFlags = if (sym.exists) sym.flags else mods.flags
820
820
if (rawFlags.is(Param )) flagMask = flagMask &~ Given
821
821
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 )
823
823
val annotations =
824
824
if (sym.exists) sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree)
825
825
else mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol))
@@ -896,7 +896,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
896
896
else {
897
897
var flags = sym.flagsUNSAFE
898
898
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))
900
900
}
901
901
902
902
override def toText (denot : Denotation ): Text = denot match {
Original file line number Diff line number Diff line change @@ -19,12 +19,15 @@ object factories {
19
19
20
20
type TypeTree = dotty.tools.dotc.ast.Trees .Tree [Type ]
21
21
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 " "
23
25
(t.symbol.flags & (if (t.symbol.isType) TypeSourceModifierFlags else TermSourceModifierFlags ))
24
- .flagStrings(t.symbol.privateWithin.name.show ).toList
26
+ .flagStrings(pwStr ).toList
25
27
.filter(_ != " <trait>" )
26
28
.filter(_ != " interface" )
27
29
.filter(_ != " case" )
30
+ }
28
31
29
32
def path (sym : Symbol )(implicit ctx : Context ): List [String ] = {
30
33
@ 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 {
4
4
inline val logging = true
5
5
}
6
6
7
+ class Logger {
8
+ protected [this ] var a = 0
9
+ protected [Logger ] var b = 0
10
+ protected var c = 0
11
+
12
+ }
13
+
7
14
object Logger {
8
15
9
16
private var indent = 0
17
+ private [this ] var a = 0
18
+ private [Logger ] var b = 0
10
19
11
20
inline def log [T ](msg : String , indentMargin : => Int )(op : => T ): T =
12
21
if (Config .logging) {
You can’t perform that action at this time.
0 commit comments