@@ -107,9 +107,18 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
107107 assert(isSatisfiable, constraint.show)
108108 }
109109
110+ private [this ] var approx : ApproxState = NoApprox
111+ protected def approxState = approx
112+
113+ protected def isSubType (tp1 : Type , tp2 : Type , a : ApproxState ): Boolean = {
114+ val saved = approx
115+ this .approx = a
116+ try recur(tp1, tp2) finally this .approx = saved
117+ }
118+
110119 protected def isSubType (tp1 : Type , tp2 : Type ): Boolean = isSubType(tp1, tp2, NoApprox )
111120
112- protected def isSubType (tp1 : Type , tp2 : Type , approx : ApproxState ): Boolean = trace(s " isSubType ${traceInfo(tp1, tp2)} $approx" , subtyping) {
121+ protected def recur (tp1 : Type , tp2 : Type ): Boolean = trace(s " isSubType ${traceInfo(tp1, tp2)} $approx" , subtyping) {
113122
114123 def monitoredIsSubType = {
115124 if (pendingSubTypes == null ) {
@@ -817,9 +826,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
817826 false
818827 } else isSubType(tp1, tp2, approx.addLow)
819828
820- def recur (tp1 : Type , tp2 : Type ) = isSubType(tp1, tp2, approx)
821-
822- // begin isSubType
829+ // begin recur
823830 if (tp2 eq NoType ) false
824831 else if (tp1 eq tp2) true
825832 else {
@@ -1655,9 +1662,9 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
16551662 case _ => String .valueOf(res)
16561663 }
16571664
1658- override def isSubType (tp1 : Type , tp2 : Type , approx : ApproxState ) =
1659- traceIndented(s " ${show(tp1)} <:< ${show(tp2)}${if (Config .verboseExplainSubtype) s " ${tp1.getClass} ${tp2.getClass}" else " " } $approx ${if (frozenConstraint) " frozen" else " " }" ) {
1660- super .isSubType(tp1, tp2, approx )
1665+ override def recur (tp1 : Type , tp2 : Type ) =
1666+ traceIndented(s " ${show(tp1)} <:< ${show(tp2)}${if (Config .verboseExplainSubtype) s " ${tp1.getClass} ${tp2.getClass}" else " " } $approxState ${if (frozenConstraint) " frozen" else " " }" ) {
1667+ super .isSubType(tp1, tp2, approxState )
16611668 }
16621669
16631670 override def hasMatchingMember (name : Name , tp1 : Type , tp2 : RefinedType ): Boolean =
0 commit comments