@@ -1435,29 +1435,33 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1435
1435
wtp.paramTypes.foreach(instantiateSelected(_, tvarsToInstantiate))
1436
1436
val constr = ctx.typerState.constraint
1437
1437
def addImplicitArgs = {
1438
- def implicitArgError (msg : => String ): Tree = {
1439
- ctx.error(msg, tree.pos.endPos)
1440
- EmptyTree
1441
- }
1442
- val args = (wtp.paramNames, wtp.paramTypes).zipped map { (pname, formal) =>
1443
- def where = d " parameter $pname of $methodStr"
1444
- inferImplicit(formal, EmptyTree , tree.pos.endPos) match {
1445
- case SearchSuccess (arg, _, _) =>
1446
- arg
1447
- case ambi : AmbiguousImplicits =>
1448
- implicitArgError(s " ambiguous implicits: ${ambi.explanation} of $where" )
1449
- case failure : SearchFailure =>
1450
- implicitArgError(d " no implicit argument of type $formal found for $where" + failure.postscript)
1451
- }
1438
+ def argsOrError (pnames : List [TermName ], ptypes : List [Type ], acc : mutable.ListBuffer [Tree ])
1439
+ : AnyRef /* List[Tree] | () => String */ = (pnames, ptypes) match {
1440
+ case (pname :: pnames1, ptype :: ptypes1) =>
1441
+ def where = d " parameter $pname of $methodStr"
1442
+ inferImplicit(ptype, EmptyTree , tree.pos.endPos) match {
1443
+ case SearchSuccess (arg, _, _) =>
1444
+ acc += arg
1445
+ argsOrError(pnames1, ptypes1, acc)
1446
+ case ambi : AmbiguousImplicits =>
1447
+ () => s " ambiguous implicits: ${ambi.explanation} of $where"
1448
+ case failure : SearchFailure =>
1449
+ () => d " no implicit argument of type $ptype found for $where" + failure.postscript
1450
+ }
1451
+ case (Nil , Nil ) =>
1452
+ acc.toList
1452
1453
}
1453
- if (args.exists(_.isEmpty)) {
1454
- // If there are several arguments, some arguments might already
1455
- // have influenced the context, binfing variables, but later ones
1456
- // might fail. In that case the constraint needs to be reset.
1457
- ctx.typerState.constraint = constr
1458
- tree
1454
+ argsOrError(wtp.paramNames, wtp.paramTypes, new mutable.ListBuffer [Tree ]) match {
1455
+ case args : List [Tree ] => adapt(tpd.Apply (tree, args), pt)
1456
+ case failure : (() => String ) =>
1457
+ // If there are several arguments, some arguments might already
1458
+ // have influenced the context, binding variables, but later ones
1459
+ // might fail. In that case the constraint needs to be reset.
1460
+ ctx.typerState.constraint = constr
1461
+ tryEither
1462
+ { implicit ctx => typed(untpd.Apply (untpd.TypedSplice (tree), Nil ), pt) }
1463
+ { (_, _) => ctx.error(failure(), tree.pos.endPos); tree }
1459
1464
}
1460
- else adapt(tpd.Apply (tree, args), pt)
1461
1465
}
1462
1466
if ((pt eq WildcardType ) || original.isEmpty) addImplicitArgs
1463
1467
else
0 commit comments