aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-10 17:10:24 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-10 17:10:24 +0200
commit0cf17c5f63b3ec37a05da920a81337067ac335db (patch)
tree18ec53eea65f57db93cb0d61794eb52f5ca0a4b5
parentab06e2d3f2749a6fd594971bee1ae0fa533fa0bd (diff)
downloaddotty-0cf17c5f63b3ec37a05da920a81337067ac335db.tar.gz
dotty-0cf17c5f63b3ec37a05da920a81337067ac335db.tar.bz2
dotty-0cf17c5f63b3ec37a05da920a81337067ac335db.zip
Align safe parameter substitution with other subst methods
Change name and align order of parameters.
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala10
2 files changed, 6 insertions, 6 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala
index fcc1a3b72..1fcebf4f0 100644
--- a/compiler/src/dotty/tools/dotc/typer/Applications.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala
@@ -395,7 +395,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
def addTyped(arg: Arg, formal: Type): Type => Type = {
addArg(typedArg(arg, formal), formal)
if (methodType.isParamDependent)
- substArgForParam(_, typeOfArg(arg), methodType.paramRefs(n))
+ safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg))
else identity
}
diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
index d04b16451..ead4ad5cb 100644
--- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -318,7 +318,7 @@ trait TypeAssigner {
/** Substitute argument type `argType` for parameter `pref` in type `tp`,
* skolemizing the argument type if it is not stable and `pref` occurs in `tp`.
*/
- def substArgForParam(tp: Type, argType: Type, pref: ParamRef)(implicit ctx: Context) = {
+ def safeSubstParam(tp: Type, pref: ParamRef, argType: Type)(implicit ctx: Context) = {
val tp1 = tp.substParam(pref, argType)
if ((tp1 eq tp) || argType.isStable) tp1
else tp.substParam(pref, SkolemType(argType.widen))
@@ -327,15 +327,15 @@ trait TypeAssigner {
def assignType(tree: untpd.Apply, fn: Tree, args: List[Tree])(implicit ctx: Context) = {
val ownType = fn.tpe.widen match {
case fntpe: MethodType =>
- def substArgsForParams(tp: Type, args: List[Tree], params: List[ParamRef]): Type = params match {
+ def safeSubstParams(tp: Type, params: List[ParamRef], args: List[Tree]): Type = params match {
case param :: params1 =>
- val tp1 = substArgForParam(tp, args.head.tpe, param)
- substArgsForParams(tp1, args.tail, params1)
+ val tp1 = safeSubstParam(tp, param, args.head.tpe)
+ safeSubstParams(tp1, params1, args.tail)
case Nil =>
tp
}
if (sameLength(fntpe.paramInfos, args) || ctx.phase.prev.relaxedTyping)
- if (fntpe.isDependent) substArgsForParams(fntpe.resultType, args, fntpe.paramRefs)
+ if (fntpe.isDependent) safeSubstParams(fntpe.resultType, fntpe.paramRefs, args)
else fntpe.resultType
else
errorType(i"wrong number of arguments for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.pos)