diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index 629bc2ed3b16..c65f732abf32 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -1104,6 +1104,8 @@ class Inliner(val call: tpd.Tree)(using Context): new TreeAccumulator[List[Symbol]] { override def apply(syms: List[Symbol], tree: tpd.Tree)(using Context): List[Symbol] = tree match { + case Closure(env, meth, tpt) if meth.symbol.isAnonymousFunction => + this(syms, tpt :: env) 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 => diff --git a/tests/pos-macros/i20353/Macro_1.scala b/tests/pos-macros/i20353/Macro_1.scala new file mode 100644 index 000000000000..7f1a914b89c6 --- /dev/null +++ b/tests/pos-macros/i20353/Macro_1.scala @@ -0,0 +1,22 @@ +//> using options -experimental -Yno-experimental + +import scala.annotation.{experimental, MacroAnnotation} +import scala.quoted.* + +class ImplicitValue + +object ImplicitValue: + inline given ImplicitValue = + ${ makeImplicitValue } + + def makeImplicitValue(using Quotes) = + import quotes.reflect.* + '{ ImplicitValue() } +end ImplicitValue + +@experimental +class Test extends MacroAnnotation: + def transform(using Quotes)(tree: quotes.reflect.Definition) = + import quotes.reflect.* + Implicits.search(TypeRepr.of[ImplicitValue]) + List(tree) diff --git a/tests/pos-macros/i20353/Test_2.scala b/tests/pos-macros/i20353/Test_2.scala new file mode 100644 index 000000000000..ebe2bb7af4b3 --- /dev/null +++ b/tests/pos-macros/i20353/Test_2.scala @@ -0,0 +1,17 @@ +//> using options -experimental -Yno-experimental + +class OuterClass: + @Test + class InnerClass + + @Test + object InnerObject +end OuterClass + +object OuterObject: + @Test + class InnerClass + + @Test + object InnerObject +end OuterObject