Skip to content

Commit 0cf17c5

Browse files
committed
Align safe parameter substitution with other subst methods
Change name and align order of parameters.
1 parent ab06e2d commit 0cf17c5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
395395
def addTyped(arg: Arg, formal: Type): Type => Type = {
396396
addArg(typedArg(arg, formal), formal)
397397
if (methodType.isParamDependent)
398-
substArgForParam(_, typeOfArg(arg), methodType.paramRefs(n))
398+
safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg))
399399
else identity
400400
}
401401

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ trait TypeAssigner {
318318
/** Substitute argument type `argType` for parameter `pref` in type `tp`,
319319
* skolemizing the argument type if it is not stable and `pref` occurs in `tp`.
320320
*/
321-
def substArgForParam(tp: Type, argType: Type, pref: ParamRef)(implicit ctx: Context) = {
321+
def safeSubstParam(tp: Type, pref: ParamRef, argType: Type)(implicit ctx: Context) = {
322322
val tp1 = tp.substParam(pref, argType)
323323
if ((tp1 eq tp) || argType.isStable) tp1
324324
else tp.substParam(pref, SkolemType(argType.widen))
@@ -327,15 +327,15 @@ trait TypeAssigner {
327327
def assignType(tree: untpd.Apply, fn: Tree, args: List[Tree])(implicit ctx: Context) = {
328328
val ownType = fn.tpe.widen match {
329329
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 {
331331
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)
334334
case Nil =>
335335
tp
336336
}
337337
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)
339339
else fntpe.resultType
340340
else
341341
errorType(i"wrong number of arguments for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.pos)

0 commit comments

Comments
 (0)