Skip to content

Commit 013b1e0

Browse files
committed
Simplify printing of scala.quoted.Type.apply
1 parent 8fdadea commit 013b1e0

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,5 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
7575

7676
override protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text =
7777
if (tree.symbol eq defn.InternalQuoted_exprQuote) "'"
78-
else if (tree.symbol eq defn.QuotedTypeModule_apply) "'[" ~ toTextGlobal(tree.args, ", ") ~ "]"
7978
else super.typeApplyText(tree)
8079
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
267267

268268
protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = {
269269
val isQuote = !printDebug && tree.fun.hasType && tree.fun.symbol == defn.QuotedTypeModule_apply
270-
val (open, close) = if (isQuote) (keywordStr("'["), keywordStr("]")) else ("[", "]")
271-
val funText = toTextLocal(tree.fun).provided(!isQuote)
270+
val funText = toTextLocal(tree.fun)
272271
tree.fun match {
273272
case Select(New(tpt), nme.CONSTRUCTOR) if tpt.typeOpt.dealias.isInstanceOf[AppliedType] =>
274273
funText // type was already printed by toText(new)
275274
case _ =>
276-
funText ~ open ~ toTextGlobal(tree.args, ", ") ~ close
275+
funText ~ "[" ~ toTextGlobal(tree.args, ", ") ~ "]"
277276
}
278277
}
279278

@@ -632,9 +631,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
632631
}
633632
case Number(digits, kind) =>
634633
digits
635-
case Quote(tree) =>
636-
if (tree.isType) keywordStr("'[") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("]")
637-
else keywordStr("'{") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("}")
634+
case Quote(tree) if tree.isTerm =>
635+
keywordStr("'{") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("}")
638636
case Splice(tree) =>
639637
keywordStr("${") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("}")
640638
case TypSplice(tree) =>

0 commit comments

Comments
 (0)