@@ -178,6 +178,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
178
178
*/
179
179
protected def normalizedFun : Tree
180
180
181
+ protected def typeOfArg (arg : Arg ): Type
182
+
181
183
/** If constructing trees, pull out all parts of the function
182
184
* which are not idempotent into separate prefix definitions
183
185
*/
@@ -380,8 +382,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
380
382
if (success) formals match {
381
383
case formal :: formals1 =>
382
384
383
- def addTyped (arg : Arg , formal : Type ) =
385
+ /** Add result of typing argument `arg` against parameter type `formal`.
386
+ * @return A type transformation to apply to all arguments following this one.
387
+ */
388
+ def addTyped (arg : Arg , formal : Type ): Type => Type = {
384
389
addArg(typedArg(arg, formal), formal)
390
+ if (methodType.isParamDependent)
391
+ _.substParam(MethodParam (methodType, n), typeOfArg(arg))
392
+ else
393
+ identity
394
+ }
385
395
386
396
def missingArg (n : Int ): Unit = {
387
397
val pname = methodType.paramNames(n)
@@ -395,8 +405,10 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
395
405
val getter = findDefaultGetter(n + numArgs(normalizedFun))
396
406
if (getter.isEmpty) missingArg(n)
397
407
else {
398
- addTyped(treeToArg(spliceMeth(getter withPos normalizedFun.pos, normalizedFun)), formal)
399
- matchArgs(args1, formals1, n + 1 )
408
+ val substParam = addTyped(
409
+ treeToArg(spliceMeth(getter withPos normalizedFun.pos, normalizedFun)),
410
+ formal)
411
+ matchArgs(args1, formals1.mapconserve(substParam), n + 1 )
400
412
}
401
413
}
402
414
@@ -420,8 +432,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
420
432
case EmptyTree :: args1 =>
421
433
tryDefault(n, args1)
422
434
case arg :: args1 =>
423
- addTyped(arg, formal)
424
- matchArgs(args1, formals1, n + 1 )
435
+ val substParam = addTyped(arg, formal)
436
+ matchArgs(args1, formals1.mapconserve(substParam) , n + 1 )
425
437
case nil =>
426
438
tryDefault(n, args)
427
439
}
@@ -477,6 +489,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
477
489
def argType (arg : Tree , formal : Type ): Type = normalize(arg.tpe, formal)
478
490
def treeToArg (arg : Tree ): Tree = arg
479
491
def isVarArg (arg : Tree ): Boolean = tpd.isWildcardStarArg(arg)
492
+ def typeOfArg (arg : Tree ): Type = arg.tpe
480
493
def harmonizeArgs (args : List [Tree ]) = harmonize(args)
481
494
}
482
495
@@ -494,6 +507,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
494
507
def argType (arg : Type , formal : Type ): Type = arg
495
508
def treeToArg (arg : Tree ): Type = arg.tpe
496
509
def isVarArg (arg : Type ): Boolean = arg.isRepeatedParam
510
+ def typeOfArg (arg : Type ): Type = arg
497
511
def harmonizeArgs (args : List [Type ]) = harmonizeTypes(args)
498
512
}
499
513
@@ -592,6 +606,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
592
606
extends TypedApply (app, fun, methRef, proto.args, resultType) {
593
607
def typedArg (arg : untpd.Tree , formal : Type ): TypedArg = proto.typedArg(arg, formal.widenExpr)
594
608
def treeToArg (arg : Tree ): untpd.Tree = untpd.TypedSplice (arg)
609
+ def typeOfArg (arg : untpd.Tree ) = proto.typeOfArg(arg)
595
610
}
596
611
597
612
/** Subclass of Application for type checking an Apply node with typed arguments. */
@@ -603,6 +618,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
603
618
// not match the abstract method in Application and an abstract class error results.
604
619
def typedArg (arg : tpd.Tree , formal : Type ): TypedArg = arg
605
620
def treeToArg (arg : Tree ): Tree = arg
621
+ def typeOfArg (arg : Tree ) = arg.tpe
606
622
}
607
623
608
624
/** If `app` is a `this(...)` constructor call, the this-call argument context,
0 commit comments