Skip to content

Commit b066d8b

Browse files
Merge pull request #6317 from dotty-staging/add-quote-debug-option
Print internal representation of ' and $ with -Yprint-debug
2 parents 5c4d462 + 53b45eb commit b066d8b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
252252
("{" ~ toText(trees, "\n") ~ "}").close
253253

254254
protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = {
255-
val isQuote = tree.fun.hasType && tree.fun.symbol == defn.InternalQuoted_typeQuote
255+
val isQuote = !ctx.settings.YprintDebug.value && tree.fun.hasType && tree.fun.symbol == defn.InternalQuoted_typeQuote
256256
val (open, close) = if (isQuote) (keywordStr("'["), keywordStr("]")) else ("[", "]")
257257
val funText = toTextLocal(tree.fun).provided(!isQuote)
258258
tree.fun match {
@@ -334,7 +334,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
334334
if (name.isTypeName) typeText(txt)
335335
else txt
336336
case tree @ Select(qual, name) =>
337-
if (tree.hasType && tree.symbol == defn.QuotedType_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}")
337+
if (!ctx.settings.YprintDebug.value && tree.hasType && tree.symbol == defn.QuotedType_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}")
338338
else if (qual.isType) toTextLocal(qual) ~ "#" ~ typeText(toText(name))
339339
else toTextLocal(qual) ~ ("." ~ nameIdText(tree) provided (name != nme.CONSTRUCTOR || ctx.settings.YprintDebug.value))
340340
case tree: This =>
@@ -346,9 +346,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
346346
changePrec (GlobalPrec) {
347347
keywordStr("throw ") ~ toText(args.head)
348348
}
349-
else if (fun.hasType && fun.symbol == defn.InternalQuoted_exprQuote)
349+
else if (!ctx.settings.YprintDebug.value && fun.hasType && fun.symbol == defn.InternalQuoted_exprQuote)
350350
keywordStr("'{") ~ toTextGlobal(args, ", ") ~ keywordStr("}")
351-
else if (fun.hasType && fun.symbol == defn.InternalQuoted_exprSplice)
351+
else if (!ctx.settings.YprintDebug.value && fun.hasType && fun.symbol == defn.InternalQuoted_exprSplice)
352352
keywordStr("${") ~ toTextGlobal(args, ", ") ~ keywordStr("}")
353353
else
354354
toTextLocal(fun) ~ "(" ~ toTextGlobal(args, ", ") ~ ")"

0 commit comments

Comments
 (0)