Skip to content

Commit da9139f

Browse files
Merge pull request #7365 from dotty-staging/i7342
Fix #7342: Incorrectly setting sources for inlined lambdas on beta reduction
2 parents dcf7cf4 + be19498 commit da9139f

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

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

+1-1
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

+5
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

+3
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

+1
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

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

0 commit comments

Comments
 (0)