@@ -318,7 +318,7 @@ trait TypeAssigner {
318
318
/** Substitute argument type `argType` for parameter `pref` in type `tp`,
319
319
* skolemizing the argument type if it is not stable and `pref` occurs in `tp`.
320
320
*/
321
- def substArgForParam (tp : Type , argType : Type , pref : ParamRef )(implicit ctx : Context ) = {
321
+ def safeSubstParam (tp : Type , pref : ParamRef , argType : Type )(implicit ctx : Context ) = {
322
322
val tp1 = tp.substParam(pref, argType)
323
323
if ((tp1 eq tp) || argType.isStable) tp1
324
324
else tp.substParam(pref, SkolemType (argType.widen))
@@ -327,15 +327,15 @@ trait TypeAssigner {
327
327
def assignType (tree : untpd.Apply , fn : Tree , args : List [Tree ])(implicit ctx : Context ) = {
328
328
val ownType = fn.tpe.widen match {
329
329
case fntpe : MethodType =>
330
- def substArgsForParams (tp : Type , args : List [Tree ], params : List [ParamRef ]): Type = params match {
330
+ def safeSubstParams (tp : Type , params : List [ParamRef ], args : List [Tree ]): Type = params match {
331
331
case param :: params1 =>
332
- val tp1 = substArgForParam (tp, args.head.tpe, param )
333
- substArgsForParams (tp1, args.tail, params1 )
332
+ val tp1 = safeSubstParam (tp, param, args.head.tpe)
333
+ safeSubstParams (tp1, params1, args.tail)
334
334
case Nil =>
335
335
tp
336
336
}
337
337
if (sameLength(fntpe.paramInfos, args) || ctx.phase.prev.relaxedTyping)
338
- if (fntpe.isDependent) substArgsForParams (fntpe.resultType, args, fntpe.paramRefs)
338
+ if (fntpe.isDependent) safeSubstParams (fntpe.resultType, fntpe.paramRefs, args )
339
339
else fntpe.resultType
340
340
else
341
341
errorType(i " wrong number of arguments for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}" , tree.pos)
0 commit comments