@@ -62,9 +62,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
6262 private var GADTused : Boolean = false
6363
6464 /** Indicates whether we have touched HKT GADT bounds */
65- private val touchedHKGADT : DynamicVariable [ Boolean ] = new DynamicVariable ( false )
65+ private var HKGADTtouched : Boolean = false
6666
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
6872
6973 private var myInstance : TypeComparer = this
7074 def currentInstance : TypeComparer = myInstance
@@ -1098,7 +1102,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10981102 val tyconIsInjective =
10991103 (tycon1sym.isClass || tycon2sym.isClass)
11001104 && (! touchedGADTs || gadtIsInstantiated)
1101- && ! touchedHKGADT.value
1105+ && ! HKGADTtouched
11021106
11031107 inFrozenGadtIf(! tyconIsInjective) {
11041108 if tycon1sym == tycon2sym && tycon1sym.isAliasType then
@@ -1180,7 +1184,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
11801184 case tycon2 : TypeRef =>
11811185 val tycon2sym = tycon2.symbol
11821186 tycon2sym.onGadtBounds { bounds2 =>
1183- HKGADTtouched { compareLower(bounds2, tyconIsTypeRef = false ) }
1187+ touchHKGadt { compareLower(bounds2, tyconIsTypeRef = false ) }
11841188 }
11851189 case _ => false
11861190 } && { GADTused = true ; true }
0 commit comments