Skip to content

Commit 2b74f88

Browse files
Merge pull request #13492 from dotty-staging/fix-#13477
Use correct context when creating inline trace
2 parents 8e92478 + 6c33e1b commit 2b74f88

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ object Inliner {
304304
*/
305305
def inlineCallTrace(callSym: Symbol, pos: SourcePosition)(using Context): Tree = {
306306
assert(ctx.source == pos.source)
307-
if (callSym.is(Macro)) ref(callSym.topLevelClass.owner).select(callSym.topLevelClass.name).withSpan(pos.span)
308-
else Ident(callSym.topLevelClass.typeRef).withSpan(pos.span)
307+
val topLevelCls = callSym.topLevelClass
308+
if (callSym.is(Macro)) ref(topLevelCls.owner).select(topLevelCls.name)(using ctx.withOwner(topLevelCls.owner)).withSpan(pos.span)
309+
else Ident(topLevelCls.typeRef).withSpan(pos.span)
309310
}
310311

311312
object Intrinsics {

tests/pos-macros/i13477/Macro.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package mylib
2+
import scala.quoted.*
3+
4+
private[mylib] object Main:
5+
transparent inline def d(): Unit = ${interpMacro}
6+
def interpMacro(using Quotes) : Expr[Unit] = '{}
7+
8+
transparent inline def f(): Unit = Main.d()

tests/pos-macros/i13477/Test.scala

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import mylib.*
2+
val x = f()

0 commit comments

Comments
 (0)