Skip to content

Commit 83047c4

Browse files
committed
Add missing Inlined node for beta-reduced by-name function
1 parent 84ccfc7 commit 83047c4

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
250250
* @param bindingsBuf the buffer to which the definition should be appended
251251
*/
252252
private def paramBindingDef(name: Name, paramtp: Type, arg: Tree,
253-
bindingsBuf: mutable.ListBuffer[ValOrDefDef]): ValOrDefDef = {
253+
bindingsBuf: mutable.ListBuffer[ValOrDefDef])(implicit ctx: Context): ValOrDefDef = {
254254
val argtpe = arg.tpe.dealiasKeepAnnots
255255
val isByName = paramtp.dealias.isInstanceOf[ExprType]
256256
var inlineFlag = InlineProxy
@@ -694,15 +694,15 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
694694
val argSyms = (mt.paramNames, mt.paramInfos, args).zipped.map { (name, paramtp, arg) =>
695695
arg.tpe.dealias match {
696696
case ref @ TermRef(NoPrefix, _) => ref.symbol
697-
case _ => paramBindingDef(name, paramtp, arg, bindingsBuf).symbol
697+
case _ => paramBindingDef(name, paramtp, arg, bindingsBuf)(ctx.withSource(cl.source)).symbol
698698
}
699699
}
700700
val expander = new TreeTypeMap(
701701
oldOwners = ddef.symbol :: Nil,
702702
newOwners = ctx.owner :: Nil,
703703
substFrom = ddef.vparamss.head.map(_.symbol),
704704
substTo = argSyms)
705-
seq(bindingsBuf.toList, expander.transform(ddef.rhs))
705+
Inlined(ddef, bindingsBuf.toList, expander.transform(ddef.rhs))
706706
case _ => tree
707707
}
708708
case _ => tree

tests/run/i4431-b/quoted_1.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
3+
object Macros {
4+
inline def h(f: => Int => String): String = f(42)
5+
}

tests/run/i4431-b/quoted_2.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted._
2+
import Macros._
3+
4+
object Test {
5+
def main(args: Array[String]): Unit = {
6+
println(h(x => "abc" + x))
7+
}
8+
}

0 commit comments

Comments
 (0)