diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index 608ac311a410..0d481ee8e0be 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -1067,6 +1067,8 @@ class Inliner(val call: tpd.Tree)(using Context): tree match { case tree: RefTree if tree.isTerm && level == -1 && tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal => foldOver(tree.symbol :: syms, tree) + case _: This if level == -1 && tree.symbol.isDefinedInCurrentRun => + tree.symbol :: syms case _: TypTree => syms case _ => foldOver(syms, tree) } diff --git a/tests/pos-macros/i18393/Inline_2.scala b/tests/pos-macros/i18393/Inline_2.scala new file mode 100644 index 000000000000..66fc9b9a135a --- /dev/null +++ b/tests/pos-macros/i18393/Inline_2.scala @@ -0,0 +1,8 @@ +package user + +import defn.Macro + +object Inline extends Macro { + inline def callMacro(): Int = + ${ this.impl() } +} diff --git a/tests/pos-macros/i18393/Macro_1.scala b/tests/pos-macros/i18393/Macro_1.scala new file mode 100644 index 000000000000..fe99162bdf84 --- /dev/null +++ b/tests/pos-macros/i18393/Macro_1.scala @@ -0,0 +1,7 @@ +package defn + +import scala.quoted.* + +abstract class Macro { + def impl()(using Quotes): Expr[Int] = '{1} +} diff --git a/tests/pos-macros/i18393/Test_2.scala b/tests/pos-macros/i18393/Test_2.scala new file mode 100644 index 000000000000..666bf5fd379f --- /dev/null +++ b/tests/pos-macros/i18393/Test_2.scala @@ -0,0 +1,5 @@ +package user + +object Test { + Inline.callMacro() +}