@@ -3564,29 +3564,32 @@ object Types {
35643564 apply(syntheticParamNames(n))(
35653565 pt => List .fill(n)(TypeBounds .empty), pt => defn.AnyType )
35663566
3567+ override def fromParams [PI <: ParamInfo .Of [TypeName ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type =
3568+ fromParams(params, resultType, useVariances = resultType.isInstanceOf [TypeBounds ])
3569+
35673570 /** Distributes Lambda inside type bounds. Examples:
35683571 *
35693572 * type T[X] = U becomes type T = [X] -> U
35703573 * type T[X] <: U becomes type T >: Nothing <: ([X] -> U)
35713574 * type T[X] >: L <: U becomes type T >: ([X] -> L) <: ([X] -> U)
35723575 */
3573- override def fromParams [PI <: ParamInfo .Of [TypeName ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type = {
3574- def expand (tp : Type , useVariances : Boolean ) = params match
3575- case ( param : Symbol ) :: _ if useVariances =>
3576+ def fromParams [PI <: ParamInfo .Of [TypeName ]](params : List [PI ], resultType : Type , useVariances : Boolean )(implicit ctx : Context ): Type = {
3577+ def expand (tp : Type , useVariances : Boolean ) =
3578+ if params.nonEmpty then
35763579 apply(params.map(_.paramName), params.map(_.paramVariance))(
35773580 tl => params.map(param => toPInfo(tl.integrate(params, param.paramInfo))),
3578- tl => tl.integrate(params, tp.resultType ))
3579- case _ =>
3581+ tl => tl.integrate(params, tp))
3582+ else
35803583 super .fromParams(params, tp)
35813584 resultType match {
35823585 case rt : AliasingBounds =>
3583- rt.derivedAlias(expand(rt.alias, true ))
3586+ rt.derivedAlias(expand(rt.alias, useVariances ))
35843587 case rt @ TypeBounds (lo, hi) =>
35853588 rt.derivedTypeBounds(
35863589 if (lo.isRef(defn.NothingClass )) lo else expand(lo, false ),
3587- expand(hi, true ))
3590+ expand(hi, useVariances ))
35883591 case rt =>
3589- expand(rt, false )
3592+ expand(rt, useVariances )
35903593 }
35913594 }
35923595 }
0 commit comments