@@ -117,8 +117,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
117117 private def isBottom (tp : Type ) = tp.widen.isRef(NothingClass )
118118
119119 protected def gadtBounds (sym : Symbol )(using Context ) = ctx.gadt.bounds(sym)
120- protected def gadtAddLowerBound (sym : Symbol , b : Type ): Boolean = ctx.gadt.addBound(sym, b, isUpper = false )
121- protected def gadtAddUpperBound (sym : Symbol , b : Type ): Boolean = ctx.gadt.addBound(sym, b, isUpper = true )
120+ protected def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean = ctx.gadt.addBound(sym, b, isUpper)
122121
123122 protected def typeVarInstance (tvar : TypeVar )(using Context ): Type = tvar.underlying
124123
@@ -1955,7 +1954,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19551954 if (bound.isRef(tparam)) false
19561955 else
19571956 val savedGadt = ctx.gadt.fresh
1958- val success = if isUpper then gadtAddUpperBound (tparam, bound) else gadtAddLowerBound(tparam, bound )
1957+ val success = gadtAddBound (tparam, bound, isUpper )
19591958 if ! success then ctx.gadt.restore(savedGadt)
19601959 success
19611960 }
@@ -2938,15 +2937,9 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29382937 super .gadtBounds(sym)
29392938 }
29402939
2941- override def gadtAddLowerBound (sym : Symbol , b : Type ): Boolean = {
2940+ override def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean =
29422941 if (sym.exists) footprint += sym.typeRef
2943- super .gadtAddLowerBound(sym, b)
2944- }
2945-
2946- override def gadtAddUpperBound (sym : Symbol , b : Type ): Boolean = {
2947- if (sym.exists) footprint += sym.typeRef
2948- super .gadtAddUpperBound(sym, b)
2949- }
2942+ super .gadtAddBound(sym, b, isUpper)
29502943
29512944 override def typeVarInstance (tvar : TypeVar )(using Context ): Type = {
29522945 footprint += tvar
@@ -3126,5 +3119,10 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
31263119 super .addConstraint(param, bound, fromBelow)
31273120 }
31283121
3122+ override def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean =
3123+ traceIndented(s " add GADT constraint ${show(sym)} ${if isUpper then " <:" else " >:" } ${show(b)} $frozenNotice, GADT constraint = ${show(ctx.gadt.debugBoundsDescription)}" ) {
3124+ super .gadtAddBound(sym, b, isUpper)
3125+ }
3126+
31293127 def lastTrace (header : String ): String = header + { try b.toString finally b.clear() }
31303128}
0 commit comments