Skip to content

Commit

Permalink
Remove color from scala.compiletime.codeOf
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicolasstucki committed Jul 28, 2021
1 parent c53cc91 commit 8e2b1a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions compiler/test-resources/repl/i13181
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scala> scala.compiletime.codeOf(1+2)
val res0: String = 1.+(2)
1 change: 1 addition & 0 deletions tests/run/i13181.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@main def Test = assert(scala.compiletime.codeOf(1+2) == "1.+(2)")

0 comments on commit 8e2b1a3

Please sign in to comment.