Skip to content

Make MatchResult Showable #15930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2907,12 +2907,19 @@ object TypeComparer {
}

object TrackingTypeComparer:
enum MatchResult:
import printing.*, Texts.*
enum MatchResult extends Showable:
case Reduced(tp: Type)
case Disjoint
case Stuck
case NoInstance(fails: List[(Name, TypeBounds)])

def toText(p: Printer): Text = this match
case Reduced(tp) => "Reduced(" ~ p.toText(tp) ~ ")"
case Disjoint => "Disjoint"
case Stuck => "Stuck"
case NoInstance(fails) => "NoInstance(" ~ Text(fails.map(p.toText(_) ~ p.toText(_)), ", ") ~ ")"

class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
import TrackingTypeComparer.*

Expand Down Expand Up @@ -2976,7 +2983,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
}

/** Match a single case. */
def matchCase(cas: Type): MatchResult = trace(i"match case $cas vs $scrut", matchTypes) {
def matchCase(cas: Type): MatchResult = trace(i"$scrut match ${MatchTypeTrace.caseText(cas)}", matchTypes, show = true) {
val cas1 = cas match {
case cas: HKTypeLambda =>
caseLambda = constrained(cas)
Expand Down