@@ -114,8 +114,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
114
114
private def isBottom (tp : Type ) = tp.widen.isRef(NothingClass )
115
115
116
116
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)
119
118
120
119
protected def typeVarInstance (tvar : TypeVar )(using Context ): Type = tvar.underlying
121
120
@@ -1947,7 +1946,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1947
1946
if (bound.isRef(tparam)) false
1948
1947
else
1949
1948
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 )
1951
1950
if ! success then ctx.gadt.restore(savedGadt)
1952
1951
success
1953
1952
}
@@ -2930,15 +2929,9 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2930
2929
super .gadtBounds(sym)
2931
2930
}
2932
2931
2933
- override def gadtAddLowerBound (sym : Symbol , b : Type ): Boolean = {
2932
+ override def gadtAddBound (sym : Symbol , b : Type , isUpper : Boolean ): Boolean =
2934
2933
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)
2942
2935
2943
2936
override def typeVarInstance (tvar : TypeVar )(using Context ): Type = {
2944
2937
footprint += tvar
@@ -3118,5 +3111,10 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
3118
3111
super .addConstraint(param, bound, fromBelow)
3119
3112
}
3120
3113
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
+
3121
3119
def lastTrace (header : String ): String = header + { try b.toString finally b.clear() }
3122
3120
}
0 commit comments