Skip to content

Gadt unification #5611

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 8 commits into from
Dec 17, 2018
Merged
Changes from 1 commit
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
15 changes: 6 additions & 9 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1822,20 +1822,17 @@ object TypeComparer {

/** Show trace of comparison operations when performing `op` as result string */
def explaining[T](say: String => Unit)(op: Context => T)(implicit ctx: Context): T = {
val (res, explanation) = underlyingExplained(op)
say(explanation)
val nestedCtx = ctx.fresh.setTypeComparerFn(new ExplainingTypeComparer(_))
val res = op(nestedCtx)
say(nestedCtx.typeComparer.lastTrace())
res
}

/** Like [[explaining]], but returns the trace instead */
def explained[T](op: Context => T)(implicit ctx: Context): String = {
underlyingExplained(op)._2
}

private def underlyingExplained[T](op: Context => T)(implicit ctx: Context): (T, String) = {
val nestedCtx = ctx.fresh.setTypeComparerFn(new ExplainingTypeComparer(_))
val res = op(nestedCtx)
(res, nestedCtx.typeComparer.lastTrace())
var trace: String = null
explaining(trace = _)(op)
trace
}
}

Expand Down