@@ -393,7 +393,7 @@ object Inferencing {
393393 def maximizeType (tp : Type , span : Span , fromScala2x : Boolean )(using Context ): List [Symbol ] = {
394394 Stats .record(" maximizeType" )
395395 val vs = variances(tp)
396- val patternBound = new mutable.ListBuffer [Symbol ]
396+ val patternBindings = new mutable.ListBuffer [( Symbol , TypeParamRef ) ]
397397 vs foreachBinding { (tvar, v) =>
398398 if (v == 1 ) tvar.instantiate(fromBelow = false )
399399 else if (v == - 1 ) tvar.instantiate(fromBelow = true )
@@ -406,11 +406,17 @@ object Inferencing {
406406 // Instead, we simultaneously add them later on.
407407 val wildCard = newPatternBoundSymbol(UniqueName .fresh(tvar.origin.paramName), bounds, span, addToGadt = false )
408408 tvar.instantiateWith(wildCard.typeRef)
409- patternBound += wildCard
409+ patternBindings += (( wildCard, tvar.origin))
410410 }
411411 }
412412 }
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+
414420 // We add the created symbols to GADT constraint here.
415421 if (res.nonEmpty) ctx.gadt.addToConstraint(res)
416422 res
0 commit comments