@@ -247,13 +247,7 @@ final class ProperGadtConstraint private(
247
247
override protected def isSame (tp1 : Type , tp2 : Type )(using Context ): Boolean = TypeComparer .isSameType(tp1, tp2)
248
248
249
249
override def nonParamBounds (param : TypeParamRef )(using Context ): TypeBounds =
250
- val externalizeMap = new TypeMap {
251
- def apply (tp : Type ): Type = tp match {
252
- case tpr : TypeParamRef => externalize(tpr)
253
- case tp => mapOver(tp)
254
- }
255
- }
256
- externalizeMap(constraint.nonParamBounds(param)).bounds
250
+ externalize(constraint.nonParamBounds(param)).bounds
257
251
258
252
override def fullLowerBound (param : TypeParamRef )(using Context ): Type =
259
253
constraint.minLower(param).foldLeft(nonParamBounds(param).lo) {
@@ -270,27 +264,27 @@ final class ProperGadtConstraint private(
270
264
271
265
// ---- Private ----------------------------------------------------------
272
266
273
- private def externalize (param : TypeParamRef )(using Context ): Type =
274
- reverseMapping(param) match {
267
+ private def externalize (tp : Type , theMap : TypeMap | Null = null )(using Context ): Type = tp match
268
+ case param : TypeParamRef => reverseMapping(param) match
275
269
case sym : Symbol => sym.typeRef
276
- case null => param
277
- }
270
+ case null => param
271
+ case tp => (if theMap == null then ExternalizeMap () else theMap).mapOver(tp)
272
+
273
+ private class ExternalizeMap (using Context ) extends TypeMap :
274
+ def apply (tp : Type ): Type = externalize(tp, this )(using mapCtx)
278
275
279
276
private def tvarOrError (sym : Symbol )(using Context ): TypeVar =
280
277
mapping(sym).ensuring(_ != null , i " not a constrainable symbol: $sym" ).uncheckedNN
281
278
282
- private def containsNoInternalTypes (
283
- tp : Type ,
284
- acc : TypeAccumulator [Boolean ] | Null = null
285
- )(using Context ): Boolean = tp match {
279
+ private def containsNoInternalTypes (tp : Type , theAcc : TypeAccumulator [Boolean ] | Null = null )(using Context ): Boolean = tp match {
286
280
case tpr : TypeParamRef => ! reverseMapping.contains(tpr)
287
281
case tv : TypeVar => ! reverseMapping.contains(tv.origin)
288
282
case tp =>
289
- (if (acc != null ) acc else new ContainsNoInternalTypesAccumulator ()).foldOver(true , tp)
283
+ (if (theAcc != null ) theAcc else new ContainsNoInternalTypesAccumulator ()).foldOver(true , tp)
290
284
}
291
285
292
286
private class ContainsNoInternalTypesAccumulator (using Context ) extends TypeAccumulator [Boolean ] {
293
- override def apply (x : Boolean , tp : Type ): Boolean = x && containsNoInternalTypes(tp)
287
+ override def apply (x : Boolean , tp : Type ): Boolean = x && containsNoInternalTypes(tp, this )
294
288
}
295
289
296
290
// ---- Debug ------------------------------------------------------------
0 commit comments