@@ -3311,14 +3311,11 @@ object Types {
33113311 def apply (paramInfos : List [PInfo ], resultType : Type )(implicit ctx : Context ): LT =
33123312 apply(syntheticParamNames(paramInfos.length), paramInfos, resultType)
33133313
3314- protected def paramName (param : ParamInfo .Of [N ])(implicit ctx : Context ): N =
3315- param.paramName
3316-
33173314 protected def toPInfo (tp : Type )(implicit ctx : Context ): PInfo
33183315
33193316 def fromParams [PI <: ParamInfo .Of [N ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type =
33203317 if (params.isEmpty) resultType
3321- else apply(params.map(paramName))(
3318+ else apply(params.map(_. paramName))(
33223319 tl => params.map(param => toPInfo(tl.integrate(params, param.paramInfo))),
33233320 tl => tl.integrate(params, resultType))
33243321 }
@@ -3562,25 +3559,29 @@ object Types {
35623559 apply(syntheticParamNames(n))(
35633560 pt => List .fill(n)(TypeBounds .empty), pt => defn.AnyType )
35643561
3565- override def paramName (param : ParamInfo .Of [TypeName ])(implicit ctx : Context ): TypeName =
3566- param.paramName.withVariance(param.paramVarianceSign)
3567-
35683562 /** Distributes Lambda inside type bounds. Examples:
35693563 *
35703564 * type T[X] = U becomes type T = [X] -> U
35713565 * type T[X] <: U becomes type T >: Nothing <: ([X] -> U)
35723566 * type T[X] >: L <: U becomes type T >: ([X] -> L) <: ([X] -> U)
35733567 */
35743568 override def fromParams [PI <: ParamInfo .Of [TypeName ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type = {
3575- def expand (tp : Type ) = super .fromParams(params, tp)
3569+ def expand (tp : Type , useVariances : Boolean ) = params match
3570+ case (param : Symbol ) :: _ if useVariances =>
3571+ apply(params.map(_.paramName), params.map(_.paramVariance))(
3572+ tl => params.map(param => toPInfo(tl.integrate(params, param.paramInfo))),
3573+ tl => tl.integrate(params, tp.resultType))
3574+ case _ =>
3575+ super .fromParams(params, tp)
35763576 resultType match {
35773577 case rt : AliasingBounds =>
3578- rt.derivedAlias(expand(rt.alias))
3578+ rt.derivedAlias(expand(rt.alias, true ))
35793579 case rt @ TypeBounds (lo, hi) =>
35803580 rt.derivedTypeBounds(
3581- if (lo.isRef(defn.NothingClass )) lo else expand(lo), expand(hi))
3581+ if (lo.isRef(defn.NothingClass )) lo else expand(lo, false ),
3582+ expand(hi, true ))
35823583 case rt =>
3583- expand(rt)
3584+ expand(rt, false )
35843585 }
35853586 }
35863587 }
0 commit comments