Skip to content

Commit

Permalink
Merge pull request #13492 from dotty-staging/fix-#13477
Browse files Browse the repository at this point in the history
Use correct context when creating inline trace
  • Loading branch information
nicolasstucki committed Sep 9, 2021
2 parents 8e92478 + 6c33e1b commit 2b74f88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Inliner.scala
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions 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()
2 changes: 2 additions & 0 deletions tests/pos-macros/i13477/Test.scala
@@ -0,0 +1,2 @@
import mylib.*
val x = f()

0 comments on commit 2b74f88

Please sign in to comment.