Skip to content

Commit a619128

Browse files
committed
Print failures in boundsViolations, via TypeComparer.explaining
1 parent ebc58f9 commit a619128

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,22 @@ object TypeOps:
691691
val hiBound = instantiate(bounds.hi, skolemizedArgTypes)
692692
val loBound = instantiate(bounds.lo, skolemizedArgTypes)
693693

694-
def check(using Context) = {
695-
if (!(lo <:< hiBound)) violations += ((arg, "upper", hiBound))
696-
if (!(loBound <:< hi)) violations += ((arg, "lower", loBound))
694+
def check(tp1: Type, tp2: Type, which: String, bound: Type)(using Context) = {
695+
val isSub = TypeComparer.explaining { cmp =>
696+
val isSub = cmp.isSubType(tp1, tp2)
697+
if !isSub then
698+
if !ctx.typerState.constraint.domainLambdas.isEmpty then
699+
typr.println(i"${ctx.typerState.constraint}")
700+
if !ctx.gadt.symbols.isEmpty then
701+
typr.println(i"${ctx.gadt}")
702+
typr.println(cmp.lastTrace(i"checkOverlapsBounds($lo, $hi, $arg, $bounds)($which)"))
703+
//trace.dumpStack()
704+
isSub
705+
}//(using ctx.fresh.setSetting(ctx.settings.verbose, true)) // uncomment to enable moreInfo in ExplainingTypeComparer recur
706+
if !isSub then violations += ((arg, which, bound))
697707
}
698-
check(using checkCtx)
708+
check(lo, hiBound, "upper", hiBound)(using checkCtx)
709+
check(loBound, hi, "lower", loBound)(using checkCtx)
699710
}
700711

701712
def loop(args: List[Tree], boundss: List[TypeBounds]): Unit = args match

0 commit comments

Comments
 (0)