@@ -2456,10 +2456,12 @@ object Types {
24562456 ctx.base.underlyingRecursions -= 1
24572457
24582458 /** The argument corresponding to class type parameter `tparam` as seen from
2459- * prefix `pre`. Can produce a TypeBounds type in case prefix is an & or | type
2460- * and parameter is non-variant.
2459+ * prefix `pre`. Can produce a TypeBounds type if `widenAbstract` is true,
2460+ * or prefix is an & or | type and parameter is non-variant.
2461+ * Otherwise, a typebounds argument is dropped and the original type parameter
2462+ * reference is returned.
24612463 */
2462- def argForParam (pre : Type )(using Context ): Type = {
2464+ def argForParam (pre : Type , widenAbstract : Boolean = false )(using Context ): Type = {
24632465 val tparam = symbol
24642466 val cls = tparam.owner
24652467 val base = pre.baseType(cls)
@@ -2471,7 +2473,7 @@ object Types {
24712473 while (tparams.nonEmpty && args.nonEmpty) {
24722474 if (tparams.head.eq(tparam))
24732475 return args.head match {
2474- case _ : TypeBounds => TypeRef (pre, tparam)
2476+ case _ : TypeBounds if ! widenAbstract => TypeRef (pre, tparam)
24752477 case arg => arg
24762478 }
24772479 tparams = tparams.tail
@@ -5806,10 +5808,10 @@ object Types {
58065808 // if H#T = U, then for any x in L..H, x.T =:= U,
58075809 // hence we can replace with U under all variances
58085810 reapply(alias.rewrapAnnots(tp1))
5809- case tp : TypeBounds =>
5811+ case bounds : TypeBounds =>
58105812 // If H#T = ? >: S <: U, then for any x in L..H, S <: x.T <: U,
58115813 // hence we can replace with S..U under all variances
5812- expandBounds(tp )
5814+ expandBounds(bounds )
58135815 case info : SingletonType =>
58145816 // if H#x: y.type, then for any x in L..H, x.type =:= y.type,
58155817 // hence we can replace with y.type under all variances
0 commit comments