File tree 4 files changed +12
-9
lines changed
compiler/src/dotty/tools/dotc
doc-tool/src/dotty/tools/dottydoc/model
4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -107,19 +107,22 @@ object Flags {
107
107
}
108
108
109
109
/** The list of non-empty names of flags that are set in this FlagSet */
110
- def flagStrings : Seq [String ] = {
110
+ def flagStrings ( privateWithin : String ) : Seq [String ] = {
111
111
val rawStrings = (2 to MaxFlag ).flatMap(flagString)
112
- if (this is Local )
112
+ val scopeStr =
113
+ if (this is Local ) " this"
114
+ else privateWithin
115
+ if (privateWithin != " " )
113
116
rawStrings.filter(_ != " <local>" ).map {
114
- case " private" => " private[this ]"
115
- case " protected" => " protected[this ]"
117
+ case " private" => s " private[ $scopeStr ] "
118
+ case " protected" => s " protected[ $scopeStr ] "
116
119
case str => str
117
120
}
118
121
else rawStrings
119
122
}
120
123
121
124
/** The string representation of this flag set */
122
- override def toString : String = flagStrings.mkString(" " )
125
+ override def toString : String = flagStrings( " " ) .mkString(" " )
123
126
}
124
127
125
128
def termFlagSet (x : Long ) = FlagSet (TERMS | x)
Original file line number Diff line number Diff line change @@ -404,7 +404,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
404
404
405
405
/** String representation of symbol's flags */
406
406
protected def toTextFlags (sym : Symbol ): Text =
407
- Text (sym.flagsUNSAFE.flagStrings map stringToText, " " )
407
+ Text (sym.flagsUNSAFE.flagStrings(nameString(sym.privateWithin.name)) map stringToText, " " )
408
408
409
409
/** String representation of symbol's variance or "" if not applicable */
410
410
protected def varianceString (sym : Symbol ): String = varianceString(sym.variance)
Original file line number Diff line number Diff line change @@ -813,7 +813,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
813
813
val rawFlags = if (sym.exists) sym.flags else mods.flags
814
814
if (rawFlags.is(Param )) flagMask = flagMask &~ Given
815
815
val flags = rawFlags & flagMask
816
- val flagsText = if (flags.isEmpty) " " else keywordStr(flags.toString )
816
+ val flagsText = if (flags.isEmpty) " " else keywordStr(flags.flagStrings(nameString(sym.privateWithin.name)).mkString( " " ) )
817
817
val annotations =
818
818
if (sym.exists) sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree)
819
819
else mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol))
@@ -888,7 +888,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
888
888
else {
889
889
var flags = sym.flagsUNSAFE
890
890
if (flags is TypeParam ) flags = flags &~ Protected
891
- Text ((flags & PrintableFlags (sym.isType)).flagStrings map (flag => stringToText(keywordStr(flag))), " " )
891
+ Text ((flags & PrintableFlags (sym.isType)).flagStrings(nameString(sym.privateWithin.name)) map (flag => stringToText(keywordStr(flag))), " " )
892
892
}
893
893
894
894
override def toText (denot : Denotation ): Text = denot match {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ object factories {
21
21
22
22
def flags (t : Tree )(implicit ctx : Context ): List [String ] =
23
23
(t.symbol.flags & (if (t.symbol.isType) TypeSourceModifierFlags else TermSourceModifierFlags ))
24
- .flagStrings.toList
24
+ .flagStrings(t.symbol.privateWithin.name.show) .toList
25
25
.filter(_ != " <trait>" )
26
26
.filter(_ != " interface" )
27
27
.filter(_ != " case" )
You can’t perform that action at this time.
0 commit comments