Skip to content

Commit 017787c

Browse files
committed
Make Given a modifier flag
This is in preparation for merging it with `Implied`. We already compensate for it when printing modifiers by eliding it when it appear with `Param`. Also, drop `hasFlag` again, since it is subsumed by the way we compute `_.mods`.
1 parent 972c15d commit 017787c

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ object Flags {
462462

463463
/** Flags representing source modifiers */
464464
private val CommonSourceModifierFlags: FlagSet =
465-
commonFlags(Private, Protected, Final, Case, Implicit, Implied, Override, JavaStatic)
465+
commonFlags(Private, Protected, Final, Case, Implicit, Implied, Given, Override, JavaStatic)
466466

467467
final val TypeSourceModifierFlags: FlagSet =
468468
CommonSourceModifierFlags.toTypeFlags | Abstract | Sealed | Opaque

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
7171

7272
protected def PrintableFlags(isType: Boolean): FlagSet = {
7373
if (isType) TypeSourceModifierFlags | Module | Local
74-
else TermSourceModifierFlags | Module | Local | Given
74+
else TermSourceModifierFlags | Module | Local
7575
}.toCommonFlags
7676

7777
override def nameString(name: Name): String =
@@ -707,7 +707,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
707707
else (txt, vparamss)
708708
(txt /: paramss)((txt, params) =>
709709
txt ~
710-
(Str(" given ") provided params.nonEmpty && hasFlag(params.head, Given)) ~
710+
(Str(" given ") provided params.nonEmpty && params.head.mods.is(Given)) ~
711711
paramsText(params))
712712
}
713713
protected def valDefToText[T >: Untyped](tree: ValDef[T]): Text = {
@@ -810,9 +810,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
810810
Text(annotations.map(annotText), " ") ~~ flagsText ~~ (Str(kw) provided !suppressKw)
811811
}
812812

813-
private def hasFlag(tree: untpd.MemberDef, flag: FlagSet): Boolean =
814-
tree.mods.is(flag) || tree.symbol.is(flag)
815-
816813
def optText(name: Name)(encl: Text => Text): Text =
817814
if (name.isEmpty) "" else encl(toText(name))
818815

0 commit comments

Comments
 (0)