Skip to content

Commit cfdb14d

Browse files
committed
Remove color from scala.compiletime.codeOf
We printed by mistake in color when the color flag was set. This was an unintetional change that happend when intinifying this operation. Fixes #13181
1 parent 31d55e0 commit cfdb14d

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)