Skip to content

Commit d851ec4

Browse files
committed
Make TypeComparer#explained take an implicit function type.
1 parent 662bd4c commit d851ec4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
195195
//}
196196
assert(!ctx.settings.YnoDeepSubtypes.value)
197197
if (Config.traceDeepSubTypeRecursions && !this.isInstanceOf[ExplainingTypeComparer])
198-
ctx.log(TypeComparer.explained(implicit ctx => ctx.typeComparer.isSubType(tp1, tp2, approx)))
198+
ctx.log(TypeComparer.explained(the[Context].typeComparer.isSubType(tp1, tp2, approx)))
199199
}
200200
// Eliminate LazyRefs before checking whether we have seen a type before
201201
val normalize = new TypeMap {
@@ -2307,15 +2307,15 @@ object TypeComparer {
23072307
*/
23082308
val FreshApprox: ApproxState = new ApproxState(4)
23092309

2310-
/** Show trace of comparison operations when performing `op` as result string */
2311-
def explaining[T](say: String => Unit)(op: Context => T)(implicit ctx: Context): T = {
2310+
/** Show trace of comparison operations when performing `op` */
2311+
def explaining[T](say: String => Unit)(op: given Context => T)(implicit ctx: Context): T = {
23122312
val nestedCtx = ctx.fresh.setTypeComparerFn(new ExplainingTypeComparer(_))
2313-
val res = try { op(nestedCtx) } finally { say(nestedCtx.typeComparer.lastTrace()) }
2313+
val res = try { op given nestedCtx } finally { say(nestedCtx.typeComparer.lastTrace()) }
23142314
res
23152315
}
23162316

23172317
/** Like [[explaining]], but returns the trace instead */
2318-
def explained[T](op: Context => T)(implicit ctx: Context): String = {
2318+
def explained[T](op: given Context => T)(implicit ctx: Context): String = {
23192319
var trace: String = null
23202320
try { explaining(trace = _)(op) } catch { case ex: Throwable => ex.printStackTrace }
23212321
trace

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

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

411411
/** Is `tp1` a subtype of `tp2`? */
412412
def isSubType(tp1: Type, tp2: Type): Boolean = {
413-
debug.println(TypeComparer.explained(implicit ctx => tp1 <:< tp2))
413+
debug.println(TypeComparer.explained(tp1 <:< tp2))
414414
val res = (tp1 != nullType || tp2 == nullType) && tp1 <:< tp2
415415
res
416416
}

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ trait Implicits { self: Typer =>
648648
case ex: AssertionError =>
649649
implicits.println(s"view $from ==> $to")
650650
implicits.println(ctx.typerState.constraint.show)
651-
implicits.println(TypeComparer.explained(implicit ctx => from.tpe <:< to))
651+
implicits.println(TypeComparer.explained(from.tpe <:< to))
652652
throw ex
653653
}
654654
}

0 commit comments

Comments
 (0)