@@ -3311,14 +3311,11 @@ object Types {
3311
3311
def apply (paramInfos : List [PInfo ], resultType : Type )(implicit ctx : Context ): LT =
3312
3312
apply(syntheticParamNames(paramInfos.length), paramInfos, resultType)
3313
3313
3314
- protected def paramName (param : ParamInfo .Of [N ])(implicit ctx : Context ): N =
3315
- param.paramName
3316
-
3317
3314
protected def toPInfo (tp : Type )(implicit ctx : Context ): PInfo
3318
3315
3319
3316
def fromParams [PI <: ParamInfo .Of [N ]](params : List [PI ], resultType : Type )(implicit ctx : Context ): Type =
3320
3317
if (params.isEmpty) resultType
3321
- else apply(params.map(paramName))(
3318
+ else apply(params.map(_. paramName))(
3322
3319
tl => params.map(param => toPInfo(tl.integrate(params, param.paramInfo))),
3323
3320
tl => tl.integrate(params, resultType))
3324
3321
}
@@ -3562,25 +3559,29 @@ object Types {
3562
3559
apply(syntheticParamNames(n))(
3563
3560
pt => List .fill(n)(TypeBounds .empty), pt => defn.AnyType )
3564
3561
3565
- override def paramName (param : ParamInfo .Of [TypeName ])(implicit ctx : Context ): TypeName =
3566
- param.paramName.withVariance(param.paramVarianceSign)
3567
-
3568
3562
/** Distributes Lambda inside type bounds. Examples:
3569
3563
*
3570
3564
* type T[X] = U becomes type T = [X] -> U
3571
3565
* type T[X] <: U becomes type T >: Nothing <: ([X] -> U)
3572
3566
* type T[X] >: L <: U becomes type T >: ([X] -> L) <: ([X] -> U)
3573
3567
*/
3574
3568
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)
3576
3576
resultType match {
3577
3577
case rt : AliasingBounds =>
3578
- rt.derivedAlias(expand(rt.alias))
3578
+ rt.derivedAlias(expand(rt.alias, true ))
3579
3579
case rt @ TypeBounds (lo, hi) =>
3580
3580
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 ))
3582
3583
case rt =>
3583
- expand(rt)
3584
+ expand(rt, false )
3584
3585
}
3585
3586
}
3586
3587
}
0 commit comments