Skip to content

Commit 73bb6c7

Browse files
Merge pull request #12193 from dotty-staging/fix-#12173
Cancel quotes while inlining
2 parents ee96970 + 2a97c3d commit 73bb6c7

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,11 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
13761376
super.typedValDef(vdef1, sym)
13771377

13781378
override def typedApply(tree: untpd.Apply, pt: Type)(using Context): Tree =
1379-
val res = constToLiteral(betaReduce(super.typedApply(tree, pt))) match {
1379+
def cancelQuotes(tree: Tree): Tree =
1380+
tree match
1381+
case Quoted(Spliced(inner)) => inner
1382+
case _ => tree
1383+
val res = cancelQuotes(constToLiteral(betaReduce(super.typedApply(tree, pt)))) match {
13801384
case res: Apply if res.symbol == defn.QuotedRuntime_exprSplice
13811385
&& level == 0
13821386
&& !hasInliningErrors =>

tests/pos-macros/i12173.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object TestMacro {
2+
inline def test[T](inline t: T): T = ${ '{ ${ 't } } }
3+
}
4+
5+
object Test {
6+
TestMacro.test("x")
7+
}

tests/pos-macros/i12173b.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object TestMacro {
2+
inline def test[T](inline t: T): T = ${ '{ ${ '{ ${ 't } } } } }
3+
}
4+
5+
object Test {
6+
TestMacro.test("x")
7+
}

tests/pos-macros/i12173c.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object TestMacro {
2+
inline def test[T](inline t: T): T = ${ '{ ${ '{ ${ '{ ${ '{ ${ '{ ${ '{ ${ '{ ${ 't } } } } } } } } } } } } } } }
3+
}
4+
5+
object Test {
6+
TestMacro.test("x")
7+
}

0 commit comments

Comments
 (0)