@@ -71,7 +71,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
71
71
72
72
protected def PrintableFlags (isType : Boolean ): FlagSet = {
73
73
if (isType) TypeSourceModifierFlags | Module | Local
74
- else TermSourceModifierFlags | Module | Local
74
+ else TermSourceModifierFlags | Module | Local | Given
75
75
}.toCommonFlags
76
76
77
77
override def nameString (name : Name ): String =
@@ -705,7 +705,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
705
705
val (leading, paramss) =
706
706
if (isExtension && vparamss.nonEmpty) (paramsText(vparamss.head) ~ " " ~ txt, vparamss.tail)
707
707
else (txt, vparamss)
708
- (txt /: paramss)((txt, params) => txt ~ paramsText(params))
708
+ (txt /: paramss)((txt, params) =>
709
+ txt ~
710
+ (Str (" given " ) provided params.nonEmpty && hasFlag(params.head, Given )) ~
711
+ paramsText(params))
709
712
}
710
713
protected def valDefToText [T >: Untyped ](tree : ValDef [T ]): Text = {
711
714
import untpd .{modsDeco => _ }
@@ -797,14 +800,19 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
797
800
else if (suppressKw) PrintableFlags (isType) &~ Private
798
801
else PrintableFlags (isType)
799
802
if (homogenizedView && mods.flags.isTypeFlags) flagMask &~= ImplicitOrImplied // drop implicit/implied from classes
800
- val flags = (if (sym.exists) sym.flags else (mods.flags)) & flagMask
803
+ val rawFlags = if (sym.exists) sym.flags else mods.flags
804
+ if (rawFlags.is(Param )) flagMask = flagMask &~ Given
805
+ val flags = rawFlags & flagMask
801
806
val flagsText = if (flags.isEmpty) " " else keywordStr(flags.toString)
802
807
val annotations =
803
808
if (sym.exists) sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree)
804
809
else mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol))
805
810
Text (annotations.map(annotText), " " ) ~~ flagsText ~~ (Str (kw) provided ! suppressKw)
806
811
}
807
812
813
+ private def hasFlag (tree : untpd.MemberDef , flag : FlagSet ): Boolean =
814
+ tree.mods.is(flag) || tree.symbol.is(flag)
815
+
808
816
def optText (name : Name )(encl : Text => Text ): Text =
809
817
if (name.isEmpty) " " else encl(toText(name))
810
818
0 commit comments