@@ -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 .*
@@ -853,12 +855,13 @@ extends Message(LossyWideningConstantConversionID):
853
855
|Write `.to $targetType` instead. """
854
856
def explain (using Context ) = " "
855
857
856
- class PatternMatchExhaustivity (uncoveredCases : Seq [String ], tree : untpd.Match )(using Context )
858
+ class PatternMatchExhaustivity (uncoveredCases : Seq [Space ], tree : untpd.Match )(using Context )
857
859
extends Message (PatternMatchExhaustivityID ) {
858
860
def kind = MessageKind .PatternMatchExhaustivity
859
861
860
862
private val hasMore = uncoveredCases.lengthCompare(6 ) > 0
861
- val uncovered = uncoveredCases.take(6 ).mkString(" , " )
863
+ val uncovered = uncoveredCases.take(6 ).map(SpaceEngine .display).mkString(" , " )
864
+ private val casesWithoutColor = inContext(ctx.withoutColors)(uncoveredCases.map(SpaceEngine .display))
862
865
863
866
def msg (using Context ) =
864
867
val addendum = if hasMore then " (More unmatched cases are elided)" else " "
@@ -886,12 +889,12 @@ extends Message(PatternMatchExhaustivityID) {
886
889
val pathes = List (
887
890
ActionPatch (
888
891
srcPos = endPos,
889
- replacement = uncoveredCases .map(c => indent(s " case $c => ??? " , startColumn))
892
+ replacement = casesWithoutColor .map(c => indent(s " case $c => ??? " , startColumn))
890
893
.mkString(" \n " , " \n " , " " )
891
894
),
892
895
)
893
896
List (
894
- CodeAction (title = s " Insert missing cases ( ${uncoveredCases .size}) " ,
897
+ CodeAction (title = s " Insert missing cases ( ${casesWithoutColor .size}) " ,
895
898
description = None ,
896
899
patches = pathes
897
900
)
0 commit comments