Skip to content

Commit 6ffa593

Browse files
committed
Move NamedArg puity check
1 parent 50c6c86 commit 6ffa593

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
370370
exprPurity(expr)
371371
case Block(stats, expr) =>
372372
minOf(exprPurity(expr), stats.map(statPurity))
373+
case NamedArg(_, expr) =>
374+
exprPurity(expr)
373375
case _ =>
374376
Impure
375377
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,19 +617,17 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
617617
typedArgs = liftArgs(argDefBuf, methType, typedArgs)
618618

619619
// Lifted arguments ordered based on the original order of typedArgBuf and
620-
// with all non explicit default parameters at the end in declaration order.
620+
// with all non-explicit default parameters at the end in declaration order.
621621
val orderedArgDefs = {
622622
// List of original arguments that are lifted by liftArgs
623-
val impureArgs = typedArgBuf.filterNot {
624-
case NamedArg(_, arg) => isPureExpr(arg)
625-
case arg => isPureExpr(arg)
626-
}
623+
val impureArgs = typedArgBuf.filterNot(isPureExpr)
624+
// Assuming stable sorting all non-explicit default parameters will remain in the end with the same order
627625
val defaultParamIndex = args.size
628626
// Mapping of index of each `liftable` into original args ordering
629627
val indices = impureArgs.map { arg =>
630628
val idx = args.indexOf(arg)
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+
if (idx >= 0) idx // original index skipping pure arguments
630+
else defaultParamIndex
633631
}
634632
scala.util.Sorting.stableSort[(Tree, Int), Int](argDefBuf zip indices, x => x._2).map(_._1)
635633
}

0 commit comments

Comments
 (0)