Skip to content

Commit 2bae1f6

Browse files
committed
Address review comments
1 parent 101fe52 commit 2bae1f6

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
@@ -463,8 +463,19 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
463463

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

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

0 commit comments

Comments
 (0)