Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,11 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
super.typedValDef(vdef1, sym)

override def typedApply(tree: untpd.Apply, pt: Type)(using Context): Tree =
val res = constToLiteral(betaReduce(super.typedApply(tree, pt))) match {
def cancelQuotes(tree: Tree): Tree =
tree match
case Quoted(Spliced(inner)) => inner
case _ => tree
val res = cancelQuotes(constToLiteral(betaReduce(super.typedApply(tree, pt)))) match {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix failed the following code:

inline def test[T](inline t: T): T = ${ identity('{ identity(${ identity('{ identity(${ identity('t) }) }) }) }) }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a different problem. I will open an issue for it. See #12225.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this one:

inline def test[T](inline t: T): T = ${ '{ ${ '{ ${ 't } } } } }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one works. Added it as a regression test.

case res: Apply if res.symbol == defn.QuotedRuntime_exprSplice
&& level == 0
&& !hasInliningErrors =>
Expand Down
7 changes: 7 additions & 0 deletions tests/pos-macros/i12173.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object TestMacro {
inline def test[T](inline t: T): T = ${ '{ ${ 't } } }
}

object Test {
TestMacro.test("x")
}
7 changes: 7 additions & 0 deletions tests/pos-macros/i12173b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object TestMacro {
inline def test[T](inline t: T): T = ${ '{ ${ '{ ${ 't } } } } }
}

object Test {
TestMacro.test("x")
}
7 changes: 7 additions & 0 deletions tests/pos-macros/i12173c.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object TestMacro {
inline def test[T](inline t: T): T = ${ '{ ${ '{ ${ '{ ${ '{ ${ '{ ${ '{ ${ '{ ${ 't } } } } } } } } } } } } } } }
}

object Test {
TestMacro.test("x")
}