Skip to content

Commit 59151bd

Browse files
committed
Print retains type trees infix
1 parent 7a282ad commit 59151bd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,16 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
527527
case RefinedTypeTree(tpt, refines) =>
528528
toTextLocal(tpt) ~ " " ~ blockText(refines)
529529
case AppliedTypeTree(tpt, args) =>
530-
if (tpt.symbol == defn.orType && args.length == 2)
530+
if tpt.symbol == defn.orType && args.length == 2 then
531531
changePrec(OrTypePrec) { toText(args(0)) ~ " | " ~ atPrec(OrTypePrec + 1) { toText(args(1)) } }
532-
else if (tpt.symbol == defn.andType && args.length == 2)
532+
else if tpt.symbol == defn.andType && args.length == 2 then
533533
changePrec(AndTypePrec) { toText(args(0)) ~ " & " ~ atPrec(AndTypePrec + 1) { toText(args(1)) } }
534+
else if tpt.symbol == defn.Predef_retainsType && args.length == 2 then
535+
changePrec(InfixPrec) { toText(args(0)) ~ " retains " ~ toText(args(1)) }
534536
else if defn.isFunctionClass(tpt.symbol)
535537
&& tpt.isInstanceOf[TypeTree] && tree.hasType && !printDebug
536-
then changePrec(GlobalPrec) { toText(tree.typeOpt) }
538+
then
539+
changePrec(GlobalPrec) { toText(tree.typeOpt) }
537540
else args match
538541
case arg :: _ if arg.isTerm =>
539542
toTextLocal(tpt) ~ "(" ~ Text(args.map(argText), ", ") ~ ")"

0 commit comments

Comments
 (0)