Skip to content

Commit

Permalink
bugfix: Fix location macro if using virtual files
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Jun 18, 2024
1 parent 37d9d0d commit 52fdc7a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ object MacroCompat {
def locationImpl()(using Quotes): Expr[Location] = {
import quotes.reflect._
val pos = Position.ofMacroExpansion
val path = pos.sourceFile.jpath.toString
val path = Option(pos.sourceFile.jpath)
.map(_.toString())
.getOrElse(pos.sourceFile.path)
val startLine = pos.startLine + 1
'{ new Location(${ Expr(path) }, ${ Expr(startLine) }) }
}
Expand Down

0 comments on commit 52fdc7a

Please sign in to comment.