Skip to content

Commit 610d37f

Browse files
committed
Fix #3614: Do not allow the SyntaxFormatter to recolor code
1 parent 63e491a commit 610d37f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,16 @@ 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 =>
8783
hb.toString
8884
case str: String if ctx.settings.color.value != "never" =>
8985
new String(SyntaxHighlighting(str).toArray)
90-
case _ => super.showArg(arg)
86+
case x :: xs =>
87+
showArg(x) + (if (xs.isEmpty) "" else ", " + showArg(xs))
88+
case _ =>
89+
super.showArg(arg)
9190
}
9291
}
9392

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,6 @@ object messages {
714714
.map(_.paramName.unexpandedName.show)
715715
.mkString("[", ", ", "]")
716716

717-
private val actualArgString = actual.map(_.show).mkString("[", ", ", "]")
718-
719717
private val prettyName =
720718
try
721719
fntpe.termSymbol match {
@@ -729,7 +727,7 @@ object messages {
729727
val msg =
730728
hl"""|${NoColor(msgPrefix)} type arguments for $prettyName$expectedArgString
731729
|expected: $expectedArgString
732-
|actual: $actualArgString""".stripMargin
730+
|actual: [$actual]""".stripMargin
733731

734732
val explanation = {
735733
val tooManyTypeParams =

0 commit comments

Comments
 (0)