@@ -107,9 +107,18 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
107
107
assert(isSatisfiable, constraint.show)
108
108
}
109
109
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
+
110
119
protected def isSubType (tp1 : Type , tp2 : Type ): Boolean = isSubType(tp1, tp2, NoApprox )
111
120
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) {
113
122
114
123
def monitoredIsSubType = {
115
124
if (pendingSubTypes == null ) {
@@ -817,9 +826,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
817
826
false
818
827
} else isSubType(tp1, tp2, approx.addLow)
819
828
820
- def recur (tp1 : Type , tp2 : Type ) = isSubType(tp1, tp2, approx)
821
-
822
- // begin isSubType
829
+ // begin recur
823
830
if (tp2 eq NoType ) false
824
831
else if (tp1 eq tp2) true
825
832
else {
@@ -1655,9 +1662,9 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
1655
1662
case _ => String .valueOf(res)
1656
1663
}
1657
1664
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 )
1661
1668
}
1662
1669
1663
1670
override def hasMatchingMember (name : Name , tp1 : Type , tp2 : RefinedType ): Boolean =
0 commit comments