diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 2068b9102899..cab9f397d507 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -379,7 +379,8 @@ object Inliner { /** Expand call to scala.compiletime.codeOf */ def codeOf(arg: Tree, pos: SrcPos)(using Context): Tree = - Literal(Constant(arg.show)).withSpan(pos.span) + val ctx1 = ctx.fresh.setSetting(ctx.settings.color, "never") + Literal(Constant(arg.show(using ctx1))).withSpan(pos.span) } extension (tp: Type) { diff --git a/compiler/test-resources/repl/i13181 b/compiler/test-resources/repl/i13181 new file mode 100644 index 000000000000..32f6c6e40c1e --- /dev/null +++ b/compiler/test-resources/repl/i13181 @@ -0,0 +1,2 @@ +scala> scala.compiletime.codeOf(1+2) +val res0: String = 1.+(2) diff --git a/tests/run/i13181.scala b/tests/run/i13181.scala new file mode 100644 index 000000000000..a6693b3f68e4 --- /dev/null +++ b/tests/run/i13181.scala @@ -0,0 +1 @@ +@main def Test = assert(scala.compiletime.codeOf(1+2) == "1.+(2)")