@@ -732,13 +732,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
732
732
/** If parameter `param` appears exactly once as an argument in `args`,
733
733
* the singleton list consisting of its position in `args`, otherwise `Nil`.
734
734
*/
735
- def paramIndices (param : untpd.ValDef , args : List [untpd.Tree ], start : Int ): List [Int ] = args match {
736
- case arg :: args1 =>
737
- if (refersTo(arg, param))
738
- if (paramIndices(param, args1, start + 1 ).isEmpty) start :: Nil
739
- else Nil
740
- else paramIndices(param, args1, start + 1 )
741
- case _ => Nil
735
+ def paramIndices (param : untpd.ValDef , args : List [untpd.Tree ]): List [Int ] = {
736
+ def loop (args : List [untpd.Tree ], start : Int ): List [Int ] = args match {
737
+ case arg :: args1 =>
738
+ val others = loop(args1, start + 1 )
739
+ if (refersTo(arg, param)) start :: others else others
740
+ case _ => Nil
741
+ }
742
+ val allIndices = loop(args, 0 )
743
+ if (allIndices.length == 1 ) allIndices else Nil
742
744
}
743
745
744
746
/** If function is of the form
@@ -752,7 +754,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
752
754
def calleeType : Type = fnBody match {
753
755
case Apply (expr, args) =>
754
756
paramIndex = {
755
- for (param <- params; idx <- paramIndices(param, args, 0 ))
757
+ for (param <- params; idx <- paramIndices(param, args))
756
758
yield param.name -> idx
757
759
}.toMap
758
760
if (paramIndex.size == params.length)
0 commit comments