Skip to content

Commit 5fee89f

Browse files
committed
Handle pure argumens while reordering
1 parent e3b3f6a commit 5fee89f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,13 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
624624
prefixShift = 1
625625
}
626626
for (l <- liftable) {
627-
if (!args.contains(l)) {
627+
val pure = l match {
628+
case NamedArg(_, arg) => isPureExpr(arg)
629+
case arg => isPureExpr(arg)
630+
}
631+
632+
if (pure) { }
633+
else if (!args.contains(l)) {
628634
indices += prefixShift + nextDefaultParamIndex
629635
nextDefaultParamIndex += 1
630636
}

tests/run/i2916.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
2
2929
5
3030

31+
1
32+
4
33+
2
34+
5
35+
3136
0
3237
1
3338
3

tests/run/i2916.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ object Test {
1313
foo(p(1), x3 = p(3), x4 = p(4), x2 = p(2)) // 1 3 4 2 5
1414
println()
1515

16+
foo(p(1), x3 = 3, x4 = p(4), x2 = p(2)) // 1 4 2 5
17+
println()
18+
1619
def test = { println(0); Test }
1720
test.foo(p(1), x3 = p(3), x4 = p(4), x2 = p(2)) // 0 1 3 4 2 5
1821
println()

0 commit comments

Comments
 (0)