Skip to content

Commit 5667bb1

Browse files
authored
Make MatchResult Showable (#15930)
2 parents 37e624f + e1f16ca commit 5667bb1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,12 +3007,19 @@ object TypeComparer {
30073007
}
30083008

30093009
object TrackingTypeComparer:
3010-
enum MatchResult:
3010+
import printing.*, Texts.*
3011+
enum MatchResult extends Showable:
30113012
case Reduced(tp: Type)
30123013
case Disjoint
30133014
case Stuck
30143015
case NoInstance(fails: List[(Name, TypeBounds)])
30153016

3017+
def toText(p: Printer): Text = this match
3018+
case Reduced(tp) => "Reduced(" ~ p.toText(tp) ~ ")"
3019+
case Disjoint => "Disjoint"
3020+
case Stuck => "Stuck"
3021+
case NoInstance(fails) => "NoInstance(" ~ Text(fails.map(p.toText(_) ~ p.toText(_)), ", ") ~ ")"
3022+
30163023
class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
30173024
import TrackingTypeComparer.*
30183025

@@ -3076,7 +3083,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
30763083
}
30773084

30783085
/** Match a single case. */
3079-
def matchCase(cas: Type): MatchResult = trace(i"match case $cas vs $scrut", matchTypes) {
3086+
def matchCase(cas: Type): MatchResult = trace(i"$scrut match ${MatchTypeTrace.caseText(cas)}", matchTypes, show = true) {
30803087
val cas1 = cas match {
30813088
case cas: HKTypeLambda =>
30823089
caseLambda = constrained(cas)

0 commit comments

Comments
 (0)