From 764a9052f55acb6b3e5cceccd8d0598f9ed62d3f Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 7 Feb 2022 16:39:36 +0100 Subject: [PATCH] Collect all local class definitions Inline accessor was generated correctly and added at the end of the class. Then transforming `bar` the `foo$inline` method was not collected yet. Fixes #14373 --- .../dotty/tools/dotc/transform/TreeMapWithStages.scala | 5 +++++ tests/pos-macros/i14373.scala | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/pos-macros/i14373.scala diff --git a/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala b/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala index c4a3ead114b0..36e71e4a1d57 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala @@ -149,6 +149,11 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap case (_:Import | _:Export) => tree + case _: Template => + val last = enteredSyms + tree.symbol.owner.info.decls.foreach(markSymbol) + mapOverTree(last) + case _ => markDef(tree) mapOverTree(enteredSyms) diff --git a/tests/pos-macros/i14373.scala b/tests/pos-macros/i14373.scala new file mode 100644 index 000000000000..95014c17b0b4 --- /dev/null +++ b/tests/pos-macros/i14373.scala @@ -0,0 +1,10 @@ +import scala.quoted._ +trait Foo +object Foo { + def apply_impl(using Quotes): Expr[Any] = '{ + new Foo { + private def foo: String = ??? + def bar: Any = ${ '{ foo }; ??? } + } + } +}