@@ -62,9 +62,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
62
62
private var GADTused : Boolean = false
63
63
64
64
/** Indicates whether we have touched HKT GADT bounds */
65
- private val touchedHKGADT : DynamicVariable [ Boolean ] = new DynamicVariable ( false )
65
+ private var HKGADTtouched : Boolean = false
66
66
67
- private def HKGADTtouched [T ](body : => T ): T = touchedHKGADT.withValue(true ) { body }
67
+ private def touchHKGadt [T ](body : => T ): T =
68
+ val savedHKGADTtouched = HKGADTtouched
69
+ val res = body
70
+ HKGADTtouched = savedHKGADTtouched
71
+ res
68
72
69
73
private var myInstance : TypeComparer = this
70
74
def currentInstance : TypeComparer = myInstance
@@ -1098,7 +1102,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1098
1102
val tyconIsInjective =
1099
1103
(tycon1sym.isClass || tycon2sym.isClass)
1100
1104
&& (! touchedGADTs || gadtIsInstantiated)
1101
- && ! touchedHKGADT.value
1105
+ && ! HKGADTtouched
1102
1106
1103
1107
inFrozenGadtIf(! tyconIsInjective) {
1104
1108
if tycon1sym == tycon2sym && tycon1sym.isAliasType then
@@ -1180,7 +1184,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1180
1184
case tycon2 : TypeRef =>
1181
1185
val tycon2sym = tycon2.symbol
1182
1186
tycon2sym.onGadtBounds { bounds2 =>
1183
- HKGADTtouched { compareLower(bounds2, tyconIsTypeRef = false ) }
1187
+ touchHKGadt { compareLower(bounds2, tyconIsTypeRef = false ) }
1184
1188
}
1185
1189
case _ => false
1186
1190
} && { GADTused = true ; true }
0 commit comments