Skip to content

Commit 762c644

Browse files
committed
Adapt printing of context functions to new syntax
1 parent 823c816 commit 762c644

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
131131
else simpleNameString(tsym)
132132
}
133133

134+
private def arrow(isGiven: Boolean): String =
135+
if isGiven then "?=>" else "=>"
136+
134137
override def toText(tp: Type): Text = controlled {
135138
def toTextTuple(args: List[Type]): Text =
136139
"(" ~ argsText(args) ~ ")"
@@ -145,19 +148,19 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
145148
atPrec(InfixPrec) { argText(args.head) }
146149
else
147150
"("
148-
~ keywordText("given ").provided(isGiven)
149151
~ keywordText("erased ").provided(isErased)
150152
~ argsText(args.init)
151153
~ ")"
152-
argStr ~ " => " ~ argText(args.last)
154+
argStr ~ " " ~ arrow(isGiven) ~ " " ~ argText(args.last)
153155
}
154156

155157
def toTextDependentFunction(appType: MethodType): Text =
156158
"("
157-
~ keywordText("given ").provided(appType.isImplicitMethod)
158159
~ keywordText("erased ").provided(appType.isErasedMethod)
159160
~ paramsText(appType)
160-
~ ") => "
161+
~ ") "
162+
~ arrow(appType.isImplicitMethod)
163+
~ " "
161164
~ toText(appType.resultType)
162165

163166
def isInfixType(tp: Type): Boolean = tp match {
@@ -577,12 +580,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
577580
case (arg @ ValDef(_, tpt, _)) :: Nil if tpt.isEmpty => argToText(arg)
578581
case _ =>
579582
"("
580-
~ keywordText("given ").provided(isGiven)
581583
~ keywordText("erased ").provided(isErased)
582584
~ Text(args.map(argToText), ", ")
583585
~ ")"
584586
}
585-
argsText ~ " => " ~ toText(body)
587+
argsText ~ " " ~ arrow(isGiven) ~ " " ~ toText(body)
586588
case PolyFunction(targs, body) =>
587589
val targsText = "[" ~ Text(targs.map((arg: Tree) => toText(arg)), ", ") ~ "]"
588590
changePrec(GlobalPrec) {

0 commit comments

Comments
 (0)