@@ -15,6 +15,8 @@ import printing.Formatting
15
15
import ErrorMessageID .*
16
16
import ast .Trees
17
17
import config .{Feature , ScalaVersion }
18
+ import transform .patmat .Space
19
+ import transform .patmat .SpaceEngine
18
20
import typer .ErrorReporting .{err , matchReductionAddendum , substitutableTypeSymbolsInScope }
19
21
import typer .ProtoTypes .{ViewProto , SelectionProto , FunProto }
20
22
import typer .Implicits .*
@@ -856,12 +858,13 @@ extends Message(LossyWideningConstantConversionID):
856
858
|Write `.to $targetType` instead. """
857
859
def explain (using Context ) = " "
858
860
859
- class PatternMatchExhaustivity (uncoveredCases : Seq [String ], tree : untpd.Match )(using Context )
861
+ class PatternMatchExhaustivity (uncoveredCases : Seq [Space ], tree : untpd.Match )(using Context )
860
862
extends Message (PatternMatchExhaustivityID ) {
861
863
def kind = MessageKind .PatternMatchExhaustivity
862
864
863
865
private val hasMore = uncoveredCases.lengthCompare(6 ) > 0
864
- val uncovered = uncoveredCases.take(6 ).mkString(" , " )
866
+ val uncovered = uncoveredCases.take(6 ).map(SpaceEngine .display).mkString(" , " )
867
+ private val casesWithoutColor = inContext(ctx.withoutColors)(uncoveredCases.map(SpaceEngine .display))
865
868
866
869
def msg (using Context ) =
867
870
val addendum = if hasMore then " (More unmatched cases are elided)" else " "
@@ -889,12 +892,12 @@ extends Message(PatternMatchExhaustivityID) {
889
892
val pathes = List (
890
893
ActionPatch (
891
894
srcPos = endPos,
892
- replacement = uncoveredCases .map(c => indent(s " case $c => ??? " , startColumn))
895
+ replacement = casesWithoutColor .map(c => indent(s " case $c => ??? " , startColumn))
893
896
.mkString(" \n " , " \n " , " " )
894
897
),
895
898
)
896
899
List (
897
- CodeAction (title = s " Insert missing cases ( ${uncoveredCases .size}) " ,
900
+ CodeAction (title = s " Insert missing cases ( ${casesWithoutColor .size}) " ,
898
901
description = None ,
899
902
patches = pathes
900
903
)
0 commit comments