Skip to content

Commit e1f16ca

Browse files
committed
Make MatchResult Showable
1 parent f0be00d commit e1f16ca

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
@@ -2907,12 +2907,19 @@ object TypeComparer {
29072907
}
29082908

29092909
object TrackingTypeComparer:
2910-
enum MatchResult:
2910+
import printing.*, Texts.*
2911+
enum MatchResult extends Showable:
29112912
case Reduced(tp: Type)
29122913
case Disjoint
29132914
case Stuck
29142915
case NoInstance(fails: List[(Name, TypeBounds)])
29152916

2917+
def toText(p: Printer): Text = this match
2918+
case Reduced(tp) => "Reduced(" ~ p.toText(tp) ~ ")"
2919+
case Disjoint => "Disjoint"
2920+
case Stuck => "Stuck"
2921+
case NoInstance(fails) => "NoInstance(" ~ Text(fails.map(p.toText(_) ~ p.toText(_)), ", ") ~ ")"
2922+
29162923
class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29172924
import TrackingTypeComparer.*
29182925

@@ -2976,7 +2983,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29762983
}
29772984

29782985
/** Match a single case. */
2979-
def matchCase(cas: Type): MatchResult = trace(i"match case $cas vs $scrut", matchTypes) {
2986+
def matchCase(cas: Type): MatchResult = trace(i"$scrut match ${MatchTypeTrace.caseText(cas)}", matchTypes, show = true) {
29802987
val cas1 = cas match {
29812988
case cas: HKTypeLambda =>
29822989
caseLambda = constrained(cas)

0 commit comments

Comments
 (0)