Skip to content

Commit 0e47303

Browse files
ghostbuster91ckipp01
authored andcommitted
Restore limit of cases in the reporter message
1 parent 7df2266 commit 0e47303

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: compiler/src/dotty/tools/dotc/reporting/messages.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,12 @@ extends Message(LossyWideningConstantConversionID):
844844
|Write `.to$targetType` instead."""
845845
def explain(using Context) = ""
846846

847-
class PatternMatchExhaustivity(val uncovered: Seq[String], tree: untpd.Match)(using Context)
847+
class PatternMatchExhaustivity(uncoveredCases: Seq[String], tree: untpd.Match)(using Context)
848848
extends Message(PatternMatchExhaustivityID) {
849849
def kind = MessageKind.PatternMatchExhaustivity
850850

851-
private val hasMore = uncovered.lengthCompare(6) > 0
851+
private val hasMore = uncoveredCases.lengthCompare(6) > 0
852+
val uncovered = uncoveredCases.take(6).mkString(", ")
852853

853854
def msg(using Context) =
854855
val addendum = if hasMore then "(More unmatched cases are elided)" else ""
@@ -870,10 +871,10 @@ extends Message(PatternMatchExhaustivityID) {
870871
val endPos = tree.cases.lastOption.map(_.endPos).getOrElse(tree.selector.endPos)
871872
val startColumn = tree.cases.lastOption.map(_.startPos.startColumn).getOrElse(tree.selector.startPos.startColumn + 2)
872873
val pathes = List(
873-
ActionPatch(endPos, uncovered.map(c=> indent(s"case $c => ???", startColumn)).mkString("\n", "\n", "")),
874+
ActionPatch(endPos, uncoveredCases.map(c=> indent(s"case $c => ???", startColumn)).mkString("\n", "\n", "")),
874875
)
875876
List(
876-
CodeAction(title = s"Insert missing cases (${uncovered.size})",
877+
CodeAction(title = s"Insert missing cases (${uncoveredCases.size})",
877878
description = None,
878879
patches = pathes
879880
)

Diff for: compiler/test/dotty/tools/dotc/reporting/TestReporter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
7575

7676
// Here we add extra information that we should know about the error message
7777
val extra = dia.msg match {
78-
case pm: PatternMatchExhaustivity => s": ${pm.uncovered.mkString("\n")}"
78+
case pm: PatternMatchExhaustivity => s": ${pm.uncovered}"
7979
case _ => ""
8080
}
8181

0 commit comments

Comments
 (0)