@@ -114,8 +114,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
114114 private def isBottom (tp : Type ) = tp.widen.isRef(NothingClass )
115115
116116 protected def gadtBounds (sym : Symbol )(using Context ) = ctx.gadt.bounds(sym)
117- protected def gadtAddLowerBound (sym : Symbol , b : Type ): Boolean = ctx.gadt.addBound(sym, b, isUpper = false )
118- protected def gadtAddUpperBound (sym : Symbol , b : Type ): Boolean = ctx.gadt.addBound(sym, b, isUpper = true )
117+ protected def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean = ctx.gadt.addBound(sym, b, isUpper)
119118
120119 protected def typeVarInstance (tvar : TypeVar )(using Context ): Type = tvar.underlying
121120
@@ -1947,7 +1946,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19471946 if (bound.isRef(tparam)) false
19481947 else
19491948 val savedGadt = ctx.gadt.fresh
1950- val success = if isUpper then gadtAddUpperBound (tparam, bound) else gadtAddLowerBound(tparam, bound )
1949+ val success = gadtAddBound (tparam, bound, isUpper )
19511950 if ! success then ctx.gadt.restore(savedGadt)
19521951 success
19531952 }
@@ -2930,15 +2929,9 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
29302929 super .gadtBounds(sym)
29312930 }
29322931
2933- override def gadtAddLowerBound (sym : Symbol , b : Type ): Boolean = {
2932+ override def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean =
29342933 if (sym.exists) footprint += sym.typeRef
2935- super .gadtAddLowerBound(sym, b)
2936- }
2937-
2938- override def gadtAddUpperBound (sym : Symbol , b : Type ): Boolean = {
2939- if (sym.exists) footprint += sym.typeRef
2940- super .gadtAddUpperBound(sym, b)
2941- }
2934+ super .gadtAddBound(sym, b, isUpper)
29422935
29432936 override def typeVarInstance (tvar : TypeVar )(using Context ): Type = {
29442937 footprint += tvar
@@ -3118,5 +3111,10 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
31183111 super .addConstraint(param, bound, fromBelow)
31193112 }
31203113
3114+ override def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean =
3115+ traceIndented(s " add GADT constraint ${show(sym)} ${if isUpper then " <:" else " >:" } ${show(b)} $frozenNotice, GADT constraint = ${show(ctx.gadt.debugBoundsDescription)}" ) {
3116+ super .gadtAddBound(sym, b, isUpper)
3117+ }
3118+
31213119 def lastTrace (header : String ): String = header + { try b.toString finally b.clear() }
31223120}
0 commit comments