Skip to content

Commit 450c0d8

Browse files
committed
Fix #3614: Do not allow the SyntaxFormatter to recolor code
1 parent 33ebbb8 commit 450c0d8

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

compiler/src/dotty/tools/dotc/printing/Formatting.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ object Formatting {
7777
class SyntaxFormatter(sc: StringContext) extends StringFormatter(sc) {
7878
override protected def showArg(arg: Any)(implicit ctx: Context): String =
7979
arg match {
80-
case arg: Showable if ctx.settings.color.value != "never" =>
81-
val highlighted =
82-
SyntaxHighlighting(wrapNonSensical(arg, super.showArg(arg)))
83-
new String(highlighted.toArray)
8480
case hl: Highlight =>
8581
hl.show
8682
case hb: HighlightBuffer =>

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ object messages {
729729
val msg =
730730
hl"""|${NoColor(msgPrefix)} type arguments for $prettyName$expectedArgString
731731
|expected: $expectedArgString
732-
|actual: $actualArgString""".stripMargin
732+
|actual: ${NoColor(actualArgString)}""".stripMargin
733733

734734
val explanation = {
735735
val tooManyTypeParams =
@@ -1418,11 +1418,11 @@ object messages {
14181418
val msg = hl"$tpe does not take type parameters"
14191419

14201420
private val ps =
1421-
if (params.size == 1) hl"a type parameter ${params.head}"
1422-
else hl"type parameters ${params.map(_.show).mkString(", ")}"
1421+
if (params.size == 1) s"a type parameter ${params.head}"
1422+
else s"type parameters ${params.map(_.show).mkString(", ")}"
14231423

14241424
val explanation =
1425-
i"""You specified $ps for ${hl"$tpe"}, which is not
1425+
i"""You specified ${NoColor(ps)} for ${hl"$tpe"}, which is not
14261426
|declared to take any.
14271427
|"""
14281428
}

0 commit comments

Comments
 (0)