@@ -131,6 +131,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
131
131
else simpleNameString(tsym)
132
132
}
133
133
134
+ private def arrow (isGiven : Boolean ): String =
135
+ if isGiven then " ?=>" else " =>"
136
+
134
137
override def toText (tp : Type ): Text = controlled {
135
138
def toTextTuple (args : List [Type ]): Text =
136
139
" (" ~ argsText(args) ~ " )"
@@ -145,19 +148,19 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
145
148
atPrec(InfixPrec ) { argText(args.head) }
146
149
else
147
150
" ("
148
- ~ keywordText(" given " ).provided(isGiven)
149
151
~ keywordText(" erased " ).provided(isErased)
150
152
~ argsText(args.init)
151
153
~ " )"
152
- argStr ~ " => " ~ argText(args.last)
154
+ argStr ~ " " ~ arrow(isGiven) ~ " " ~ argText(args.last)
153
155
}
154
156
155
157
def toTextDependentFunction (appType : MethodType ): Text =
156
158
" ("
157
- ~ keywordText(" given " ).provided(appType.isImplicitMethod)
158
159
~ keywordText(" erased " ).provided(appType.isErasedMethod)
159
160
~ paramsText(appType)
160
- ~ " ) => "
161
+ ~ " ) "
162
+ ~ arrow(appType.isImplicitMethod)
163
+ ~ " "
161
164
~ toText(appType.resultType)
162
165
163
166
def isInfixType (tp : Type ): Boolean = tp match {
@@ -386,8 +389,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
386
389
keywordStr(" ${" ) ~ toTextGlobal(args, " , " ) ~ keywordStr(" }" )
387
390
else
388
391
toTextLocal(fun)
392
+ ~ (" ." ~ keywordText(" with" )).provided(app.isGivenApply && ! homogenizedView)
389
393
~ " ("
390
- ~ keywordText(" given " ).provided(app.isGivenApply && ! homogenizedView)
391
394
~ toTextGlobal(args, " , " )
392
395
~ " )"
393
396
case tree : TypeApply =>
@@ -577,12 +580,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
577
580
case (arg @ ValDef (_, tpt, _)) :: Nil if tpt.isEmpty => argToText(arg)
578
581
case _ =>
579
582
" ("
580
- ~ keywordText(" given " ).provided(isGiven)
581
583
~ keywordText(" erased " ).provided(isErased)
582
584
~ Text (args.map(argToText), " , " )
583
585
~ " )"
584
586
}
585
- argsText ~ " => " ~ toText(body)
587
+ argsText ~ " " ~ arrow(isGiven) ~ " " ~ toText(body)
586
588
case PolyFunction (targs, body) =>
587
589
val targsText = " [" ~ Text (targs.map((arg : Tree ) => toText(arg)), " , " ) ~ " ]"
588
590
changePrec(GlobalPrec ) {
@@ -770,10 +772,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
770
772
}
771
773
772
774
private def paramsText [T >: Untyped ](params : List [ValDef [T ]]) =
773
- " ("
774
- ~ keywordText(" given " ).provided(params.nonEmpty && params.head.mods.is(Given ))
775
- ~ toText(params, " , " )
776
- ~ " )"
775
+ keywordText(" with " ).provided(params.nonEmpty && params.head.mods.is(Given ))
776
+ ~ " (" ~ toText(params, " , " ) ~ " )"
777
777
778
778
protected def defDefToText [T >: Untyped ](tree : DefDef [T ]): Text = {
779
779
import untpd .{modsDeco => _ }
0 commit comments