Skip to content

Commit 6b11e04

Browse files
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 02e954a commit 6b11e04

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
@@ -779,7 +779,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
779779
newOwners = ctx.owner :: Nil,
780780
substFrom = ddef.vparamss.head.map(_.symbol),
781781
substTo = argSyms)
782-
Inlined(ddef, bindingsBuf.toList, expander.transform(ddef.rhs))
782+
Block(bindingsBuf.toList, expander.transform(ddef.rhs))
783783
case _ => tree
784784
}
785785
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])(given 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])(given 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)