File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -750,13 +750,23 @@ trait Applications extends Compatibility {
750750 }
751751 private def sameSeq [T <: Trees .Tree [? ]](xs : List [T ], ys : List [T ]): Boolean = firstDiff(xs, ys) < 0
752752
753+ /** An argument is safe if it is a pure expression or a default getter call
754+ * If all arguments are safe, no reordering is necessary
755+ */
756+ def isSafeArg (arg : Tree ) =
757+ isPureExpr(arg)
758+ || arg.isInstanceOf [RefTree | Apply | TypeApply ] && arg.symbol.name.is(DefaultGetterName )
759+
753760 val result : Tree = {
754761 var typedArgs = typedArgBuf.toList
755762 def app0 = cpy.Apply (app)(normalizedFun, typedArgs) // needs to be a `def` because typedArgs can change later
756763 val app1 =
757764 if (! success) app0.withType(UnspecifiedErrorType )
758765 else {
759- if ! sameSeq(args, orderedArgs) && ! isJavaAnnotConstr(methRef.symbol) then
766+ if ! sameSeq(args, orderedArgs)
767+ && ! isJavaAnnotConstr(methRef.symbol)
768+ && ! typedArgs.forall(isSafeArg)
769+ then
760770 // need to lift arguments to maintain evaluation order in the
761771 // presence of argument reorderings.
762772
You can’t perform that action at this time.
0 commit comments