@@ -613,21 +613,25 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
613
613
liftFun()
614
614
615
615
// lift arguments in the definition order
616
- val argDefBuff = mutable.ListBuffer .empty[Tree ]
617
- typedArgs = liftArgs(argDefBuff, methType, typedArgs)
618
-
619
- def orderedArgDefs = {
620
- val impureArgs = typedArgBuf.filterNot { // pure are not lifted by liftArgs
616
+ val argDefBuf = mutable.ListBuffer .empty[Tree ]
617
+ typedArgs = liftArgs(argDefBuf, methType, typedArgs)
618
+
619
+ // Lifted arguments ordered based on the original order of typedArgBuf and
620
+ // with all non explicit default parameters at the end in declaration order.
621
+ val orderedArgDefs = {
622
+ // List of original arguments that are lifted by liftArgs
623
+ val impureArgs = typedArgBuf.filterNot {
621
624
case NamedArg (_, arg) => isPureExpr(arg)
622
625
case arg => isPureExpr(arg)
623
626
}
624
- var defaultParamIndex = args.size
627
+ val defaultParamIndex = args.size
625
628
// Mapping of index of each `liftable` into original args ordering
626
629
val indices = impureArgs.map { arg =>
627
630
val idx = args.indexOf(arg)
628
- if (idx >= 0 ) idx else defaultParamIndex // assuming stable sorting
631
+ if (idx >= 0 ) idx // original index skipping pure agruments
632
+ else defaultParamIndex // assuming stable sorting all will remain in the end with the same order
629
633
}
630
- scala.util.Sorting .stableSort[(Tree , Int ), Int ](argDefBuff zip indices, x => x._2).map(_._1)
634
+ scala.util.Sorting .stableSort[(Tree , Int ), Int ](argDefBuf zip indices, x => x._2).map(_._1)
631
635
}
632
636
633
637
liftedDefs ++= orderedArgDefs
0 commit comments