Skip to content

Commit 6747160

Browse files
committed
Allow RefinedPrinter to print HOAS patterns with type params
1 parent 1703a04 commit 6747160

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
750750
val close = if (body.isTerm) keywordStr("}") else keywordStr("]")
751751
keywordStr("'") ~ quotesText ~ open ~ bindingsText ~ toTextGlobal(body) ~ close
752752
case SplicePattern(pattern, typeargs, args) =>
753-
// TODO-18271: print `typeargs`
753+
// TODO-18271: Add tests?
754754
val spliceTypeText = (keywordStr("[") ~ toTextGlobal(tree.typeOpt) ~ keywordStr("]")).provided(printDebug && tree.typeOpt.exists)
755755
keywordStr("$") ~ spliceTypeText ~ {
756-
if args.isEmpty then keywordStr("{") ~ inPattern(toText(pattern)) ~ keywordStr("}")
757-
else toText(pattern.symbol.name) ~ "(" ~ toTextGlobal(args, ", ") ~ ")"
756+
if typeargs.isEmpty && args.isEmpty then keywordStr("{") ~ inPattern(toText(pattern)) ~ keywordStr("}")
757+
else if typeargs.isEmpty then toText(pattern.symbol.name) ~ "(" ~ toTextGlobal(args, ", ") ~ ")"
758+
else toText(pattern.symbol.name) ~ "[" ~ toTextGlobal(typeargs, ", ")~ "]" ~ "(" ~ toTextGlobal(args, ", ") ~ ")"
758759
}
759760
case Hole(isTerm, idx, args, content) =>
760761
val (prefix, postfix) = if isTerm then ("{{{", "}}}") else ("[[[", "]]]")

0 commit comments

Comments
 (0)