Skip to content

Commit

Permalink
Merge pull request #796 from tgodzik/fix-npe
Browse files Browse the repository at this point in the history
bugfix: Fix location macro if using virtual files
  • Loading branch information
tgodzik authored Jun 18, 2024
2 parents 37d9d0d + 1f3ff5a commit 981e0f2
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 = pos.sourceFile.getJPath
.map(_.toString())
.getOrElse(pos.sourceFile.path)
val startLine = pos.startLine + 1
'{ new Location(${ Expr(path) }, ${ Expr(startLine) }) }
}
Expand Down

0 comments on commit 981e0f2

Please sign in to comment.