Skip to content

Commit a5f967e

Browse files
committed
Simplify mods.annotations filtering
1 parent 241bd91 commit a5f967e

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,8 @@ import scala.language.implicitConversions
1212

1313
class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
1414

15-
override protected def modText(mods: untpd.Modifiers, kw: String): Text = { // DD
16-
val suppressKw = if (enclDefIsClass) mods is ParamAndLocal else mods is Param
17-
var flagMask =
18-
if (ctx.settings.YdebugFlags.value) AnyFlags
19-
else if (suppressKw) PrintableFlags &~ Private
20-
else PrintableFlags
21-
if (homogenizedView && mods.flags.isTypeFlags) flagMask &~= Implicit // drop implicit from classes
22-
val flags = mods.flags & flagMask
23-
val flagsText = if (flags.isEmpty) "" else keywordStr((mods.flags & flagMask).toString)
24-
val annotations = mods.annotations.filter(_.tpe != defn.SourceFileAnnotType)
25-
Text(annotations.map(annotText), " ") ~~ flagsText ~~ (Str(kw) provided !suppressKw)
26-
}
15+
override protected def filterModTextAnnots(annots: List[untpd.Tree]): List[untpd.Tree] =
16+
annots.filter(_.tpe != defn.SourceFileAnnotType)
2717

2818
override protected def blockText[T >: Untyped](trees: List[Trees.Tree[T]]): Text = {
2919
super.blockText(trees.filterNot(_.isInstanceOf[Closure[_]]))

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
690690
if (homogenizedView && mods.flags.isTypeFlags) flagMask &~= Implicit // drop implicit from classes
691691
val flags = mods.flags & flagMask
692692
val flagsText = if (flags.isEmpty) "" else keywordStr((mods.flags & flagMask).toString)
693-
Text(mods.annotations.map(annotText), " ") ~~ flagsText ~~ (Str(kw) provided !suppressKw)
693+
val annotations = filterModTextAnnots(mods.annotations)
694+
Text(annotations.map(annotText), " ") ~~ flagsText ~~ (Str(kw) provided !suppressKw)
694695
}
695696

697+
protected def filterModTextAnnots(annots: List[untpd.Tree]): List[untpd.Tree] = annots
698+
696699
def optText(name: Name)(encl: Text => Text): Text =
697700
if (name.isEmpty) "" else encl(toText(name))
698701

0 commit comments

Comments
 (0)