Skip to content

Commit 5c6d352

Browse files
Merge pull request scala#13186 from dotty-staging/fix-#13181
Remove color from scala.compiletime.codeOf
2 parents 7bf5d4f + cfdb14d commit 5c6d352

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ object Inliner {
379379

380380
/** Expand call to scala.compiletime.codeOf */
381381
def codeOf(arg: Tree, pos: SrcPos)(using Context): Tree =
382-
Literal(Constant(arg.show)).withSpan(pos.span)
382+
val ctx1 = ctx.fresh.setSetting(ctx.settings.color, "never")
383+
Literal(Constant(arg.show(using ctx1))).withSpan(pos.span)
383384
}
384385

385386
extension (tp: Type) {

compiler/test-resources/repl/i13181

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
scala> scala.compiletime.codeOf(1+2)
2+
val res0: String = 1.+(2)

tests/run/i13181.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@main def Test = assert(scala.compiletime.codeOf(1+2) == "1.+(2)")

0 commit comments

Comments
 (0)