Skip to content

Commit f4eff10

Browse files
committed
Fix optimization
Can't lift bindings from arguments as this might change evaluation order and it also does not work for cbn parameters. Also, fix stray printing
1 parent a0795e2 commit f4eff10

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ object Inliner {
102102

103103
val bindings = new mutable.ListBuffer[Tree]
104104

105-
/** Lift bindings in function or argument of inline call to
105+
/** Lift bindings around inline call or in its function part to
106106
* the `bindings` buffer. This is done as an optimization to keep
107107
* inline call expansions smaller.
108108
*/
@@ -115,15 +115,15 @@ object Inliner {
115115
val lifter = liftFromInlined(call)
116116
cpy.Inlined(tree)(call, Nil, liftBindings(expr, liftFromInlined(call).transform(_)))
117117
case Apply(fn, args) =>
118-
cpy.Apply(tree)(liftBindings(fn, liftPos), args.map(liftBindings(_, liftPos)))
118+
cpy.Apply(tree)(liftBindings(fn, liftPos), args)
119119
case TypeApply(fn, args) =>
120120
cpy.TypeApply(tree)(liftBindings(fn, liftPos), args)
121121
case Select(qual, name) =>
122122
cpy.Select(tree)(liftBindings(qual, liftPos), name)
123123
case _ =>
124124
tree
125125
}
126-
126+
127127
val tree1 = liftBindings(tree, identity)
128128
if (bindings.nonEmpty)
129129
cpy.Block(tree)(bindings.toList, inlineCall(tree1, pt))
@@ -511,7 +511,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
511511
else letBindUnless(TreeInfo.Pure, arg)(seq(trailing, _))
512512
val fullArg = seq(prefix, seq(leading, argInPlace))
513513
new TreeTypeMap().transform(fullArg) // make sure local bindings in argument have fresh symbols
514-
.reporting(res => i"projecting $tree -> $res")
514+
.reporting(res => i"projecting $tree -> $res", inlining)
515515
}
516516
else tree
517517
case Block(stats, expr) if stats.forall(isPureBinding) =>

0 commit comments

Comments
 (0)