diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index db6165ed5f2f..d704bcee3f1f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -892,7 +892,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { else def argsSpan = trailing.map(_.span).foldLeft(arg.span)(_.union(_)) letBindUnless(TreeInfo.Pure, arg)(Block(trailing, _).withSpan(argsSpan)) - finish(seq(prefix, seq(leading, argInPlace))) + val blockSpan = (prefix ::: leading).map(_.span).foldLeft(argInPlace.span)(_.union(_)) + finish(seq(prefix, seq(leading, argInPlace)).withSpan(blockSpan)) } } else tree diff --git a/tests/run-macros/i10880/Dsl_1.scala b/tests/run-macros/i10880/Dsl_1.scala new file mode 100644 index 000000000000..cdf937fa2907 --- /dev/null +++ b/tests/run-macros/i10880/Dsl_1.scala @@ -0,0 +1,9 @@ +trait Ent(name: String) +case class MyContent(key: String, value: String) +case class MyInsert(key: String) + +object Dsl { + inline def ent: Ent = new Ent("something") {} + extension (ent: Ent) + inline def content(inline ins: MyInsert) = MyContent(ins.key, "blah") +} diff --git a/tests/run-macros/i10880/MyQuoteMacro_1.scala b/tests/run-macros/i10880/MyQuoteMacro_1.scala new file mode 100644 index 000000000000..31576cc6fe63 --- /dev/null +++ b/tests/run-macros/i10880/MyQuoteMacro_1.scala @@ -0,0 +1,11 @@ +import scala.quoted._ + +case class MyQuoted(val ast: String, sub: String) + +object MyQuoteMacro { + inline def myquote(inline content: MyContent): MyQuoted = ${ MyQuoteMacro.apply('content) } + def apply(content: Expr[MyContent])(using Quotes): Expr[MyQuoted] = { + import quotes.reflect._ + '{ MyQuoted($content.key, null) } + } +} diff --git a/tests/run-macros/i10880/PullAst_1.scala b/tests/run-macros/i10880/PullAst_1.scala new file mode 100644 index 000000000000..7440ddf7a90d --- /dev/null +++ b/tests/run-macros/i10880/PullAst_1.scala @@ -0,0 +1,9 @@ +import scala.quoted._ + +object PullAst { + def applyImpl(quoted: Expr[MyQuoted])(using qctx: Quotes): Expr[String] = + '{ $quoted.ast.toString } + + inline def apply(inline quoted: MyQuoted): String = + ${ applyImpl('quoted) } +} diff --git a/tests/run-macros/i10880/Test_2.scala b/tests/run-macros/i10880/Test_2.scala new file mode 100644 index 000000000000..67833b7639e7 --- /dev/null +++ b/tests/run-macros/i10880/Test_2.scala @@ -0,0 +1,9 @@ +object Test { + import Dsl._ + + inline def q2 = MyQuoteMacro.myquote(ent.content(MyInsert("Foo"))) + + def main(args: Array[String]): Unit = { + println( PullAst.apply( q2 ) ) + } +}