Skip to content

Commit 52c13e2

Browse files
committed
Improve debugging for explained
1 parent 8ecc927 commit 52c13e2

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,15 +2076,14 @@ object TypeComparer {
20762076
/** Show trace of comparison operations when performing `op` as result string */
20772077
def explaining[T](say: String => Unit)(op: Context => T)(implicit ctx: Context): T = {
20782078
val nestedCtx = ctx.fresh.setTypeComparerFn(new ExplainingTypeComparer(_))
2079-
val res = op(nestedCtx)
2080-
say(nestedCtx.typeComparer.lastTrace())
2079+
val res = try { op(nestedCtx) } finally { say(nestedCtx.typeComparer.lastTrace()) }
20812080
res
20822081
}
20832082

20842083
/** Like [[explaining]], but returns the trace instead */
20852084
def explained[T](op: Context => T)(implicit ctx: Context): String = {
20862085
var trace: String = null
2087-
explaining(trace = _)(op)
2086+
try { explaining(trace = _)(op) } catch { case ex: Throwable => ex.printStackTrace }
20882087
trace
20892088
}
20902089
}

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
405405

406406
/** Is `tp1` a subtype of `tp2`? */
407407
def isSubType(tp1: Type, tp2: Type): Boolean = {
408+
debug.println(TypeComparer.explained(implicit ctx => tp1 <:< tp2))
408409
val res = (tp1 != nullType || tp2 == nullType) && tp1 <:< tp2
409-
debug.println(s"${tp1} <:< ${tp2} = $res")
410410
res
411411
}
412412

0 commit comments

Comments
 (0)