Skip to content

Commit 6e27f43

Browse files
committed
Avoid direct use of SourceCodePrinter
1 parent 4323fd0 commit 6e27f43

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ object QuoteContextImpl {
1616

1717
def showTree(tree: tpd.Tree)(using Context): String = {
1818
val qctx = QuoteContextImpl()(using MacroExpansion.context(tree))
19-
val reflCtx = ctx.asInstanceOf[qctx.tasty.Context]
20-
val reflTree = tree.asInstanceOf[qctx.tasty.Tree]
2119
val syntaxHighlight =
2220
if (ctx.settings.color.value == "always") SyntaxHighlight.ANSI
2321
else SyntaxHighlight.plain
24-
new scala.tasty.reflect.SourceCodePrinter[qctx.tasty.type](qctx.tasty)(syntaxHighlight).showTree(reflTree)(using reflCtx)
22+
show(using qctx)(tree.asInstanceOf[qctx.tasty.Tree], syntaxHighlight)(using ctx.asInstanceOf[qctx.tasty.Context])
2523
}
2624

25+
private def show(using qctx: QuoteContext)(tree: qctx.tasty.Tree, syntaxHighlight: SyntaxHighlight)(using qctx.tasty.Context) =
26+
tree.showWith(syntaxHighlight)
27+
2728
private[dotty] def checkScopeId(id: ScopeId)(using Context): Unit =
2829
if (id != scopeId)
2930
throw new scala.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")

0 commit comments

Comments
 (0)