@@ -393,7 +393,7 @@ object Inferencing {
393
393
def maximizeType (tp : Type , span : Span , fromScala2x : Boolean )(using Context ): List [Symbol ] = {
394
394
Stats .record(" maximizeType" )
395
395
val vs = variances(tp)
396
- val patternBound = new mutable.ListBuffer [Symbol ]
396
+ val patternBindings = new mutable.ListBuffer [( Symbol , TypeParamRef ) ]
397
397
vs foreachBinding { (tvar, v) =>
398
398
if (v == 1 ) tvar.instantiate(fromBelow = false )
399
399
else if (v == - 1 ) tvar.instantiate(fromBelow = true )
@@ -406,11 +406,17 @@ object Inferencing {
406
406
// Instead, we simultaneously add them later on.
407
407
val wildCard = newPatternBoundSymbol(UniqueName .fresh(tvar.origin.paramName), bounds, span, addToGadt = false )
408
408
tvar.instantiateWith(wildCard.typeRef)
409
- patternBound += wildCard
409
+ patternBindings += (( wildCard, tvar.origin))
410
410
}
411
411
}
412
412
}
413
- val res = patternBound.toList
413
+ val res = patternBindings.toList.map { (boundSym, _) =>
414
+ // substitute bounds of pattern bound variables to deal with possible F-bounds
415
+ for (wildCard, param) <- patternBindings do
416
+ boundSym.info = boundSym.info.substParam(param, wildCard.typeRef)
417
+ boundSym
418
+ }
419
+
414
420
// We add the created symbols to GADT constraint here.
415
421
if (res.nonEmpty) ctx.gadt.addToConstraint(res)
416
422
res
0 commit comments