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