Skip to content

Commit be19498

Browse files
anatoliykmetyuknicolasstucki
authored andcommitted
Fix #7342: Incorrectly setting sources for inlined lambdas on beta reduction
On beta reduction of lambdas, we should create a block and not an inline node.
1 parent dcf7cf4 commit be19498

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
817817
newOwners = ctx.owner :: Nil,
818818
substFrom = ddef.vparamss.head.map(_.symbol),
819819
substTo = argSyms)
820-
Inlined(ddef, bindingsBuf.toList, expander.transform(ddef.rhs))
820+
Block(bindingsBuf.toList, expander.transform(ddef.rhs))
821821
case _ => tree
822822
}
823823
case _ => tree

tests/pos-macros/i7342/Macro_1.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted.{ QuoteContext, Expr }
2+
3+
trait Foo
4+
5+
inline def g(em: Expr[Foo])(using QuoteContext) = '{$em}

tests/pos-macros/i7342/Macro_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.quoted.{ QuoteContext, Expr }
2+
3+
def h(m: Expr[Foo])(using QuoteContext): Expr[Any] = g(m)

tests/pos/i7342/First_1.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
inline def g(em: Int) = ((c: Int) => em).apply({println("AAAAAAA"); 1})

tests/pos/i7342/Second_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def h(m: Int) = g(m)

0 commit comments

Comments
 (0)