diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 60cf13d46f5f..4895da94c56c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -304,8 +304,9 @@ object Inliner { */ def inlineCallTrace(callSym: Symbol, pos: SourcePosition)(using Context): Tree = { assert(ctx.source == pos.source) - if (callSym.is(Macro)) ref(callSym.topLevelClass.owner).select(callSym.topLevelClass.name).withSpan(pos.span) - else Ident(callSym.topLevelClass.typeRef).withSpan(pos.span) + val topLevelCls = callSym.topLevelClass + if (callSym.is(Macro)) ref(topLevelCls.owner).select(topLevelCls.name)(using ctx.withOwner(topLevelCls.owner)).withSpan(pos.span) + else Ident(topLevelCls.typeRef).withSpan(pos.span) } object Intrinsics { diff --git a/tests/pos-macros/i13477/Macro.scala b/tests/pos-macros/i13477/Macro.scala new file mode 100644 index 000000000000..fe58549bc7e5 --- /dev/null +++ b/tests/pos-macros/i13477/Macro.scala @@ -0,0 +1,8 @@ +package mylib +import scala.quoted.* + +private[mylib] object Main: + transparent inline def d(): Unit = ${interpMacro} + def interpMacro(using Quotes) : Expr[Unit] = '{} + +transparent inline def f(): Unit = Main.d() diff --git a/tests/pos-macros/i13477/Test.scala b/tests/pos-macros/i13477/Test.scala new file mode 100644 index 000000000000..60dadf0a21df --- /dev/null +++ b/tests/pos-macros/i13477/Test.scala @@ -0,0 +1,2 @@ +import mylib.* +val x = f()