Skip to content

Commit 0c7ef13

Browse files
committed
Address review comments
1 parent d2c19ce commit 0c7ef13

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,19 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
468468

469469
override def typedApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context) = {
470470

471+
/** Rewrite an application
472+
*
473+
* ((x1, ..., sn) => b)(e1, ..., en)
474+
*
475+
* to
476+
*
477+
* val/def x1 = e1; ...; val/def xn = en; b
478+
*
479+
* where `def` is used for call-by-name parameters. However, we shortcut any NoPrefix
480+
* refs among the ei's directly without creating an intermediate binding.
481+
*/
471482
def betaReduce(tree: Tree) = tree match {
472-
case Apply(Select(cl @ closureDef(ddef), nme.apply), args) =>
483+
case Apply(Select(cl @ closureDef(ddef), nme.apply), args) if defn.isFunctionType(cl.tpe) =>
473484
ddef.tpe.widen match {
474485
case mt: MethodType if ddef.vparamss.head.length == args.length =>
475486
val bindingsBuf = new mutable.ListBuffer[ValOrDefDef]

0 commit comments

Comments
 (0)