Skip to content

Commit be27da0

Browse files
committed
Fix firstDiff
1 parent 5fee89f commit be27da0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
590590
private def firstDiff[T <: Trees.Tree[_]](xs: List[T], ys: List[T], n: Int = 0): Int = xs match {
591591
case x :: xs1 =>
592592
ys match {
593-
case EmptyTree :: ys1 => firstDiff(xs1, ys1, n)
593+
case EmptyTree :: ys1 => firstDiff(xs, ys1, n)
594594
case y :: ys1 => if (x ne y) n else firstDiff(xs1, ys1, n + 1)
595595
case nil => n
596596
}
@@ -609,7 +609,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
609609
val app1 =
610610
if (!success) app0.withType(UnspecifiedErrorType)
611611
else {
612-
if (!sameSeq(args, orderedArgs) && !isJavaAnnotConstr(methRef.symbol)) {
612+
if (!(sameSeq(args, orderedArgs) && !orderedArgs.contains(EmptyTree)) && !isJavaAnnotConstr(methRef.symbol)) {
613613
// need to lift arguments to maintain evaluation order in the
614614
// presence of argument reorderings.
615615
liftFun()

tests/run/i2916.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@
4646
4
4747
2
4848
5
49+
50+
1
51+
3
52+
2

tests/run/i2916.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
object Test {
22
def p(x: Int) = { println(x); x }
33
def foo(x1: Int, x2: Int, x3: Int, x4: Int = p(4), x5: Int = p(5)) = 1
4+
def traceIndented(x1: Int, x2: Int = p(2), x3: Int = p(3)) = ()
45
def main(args: Array[String]) = {
56
foo(p(1), p(2), p(3)) // 1 2 3 4 5
67
println()
@@ -21,5 +22,9 @@ object Test {
2122
println()
2223

2324
{ println(0); Test }.foo(p(1), x3 = p(3), x4 = p(4), x2 = p(2)) // 0 1 3 4 2 5
25+
println()
26+
27+
traceIndented(p(1), x3 = p(3))
28+
2429
}
2530
}

0 commit comments

Comments
 (0)