Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct context when creating inline trace #13492

Merged
merged 1 commit into from Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()