Skip to content

Commit

Permalink
Get source location for non-JVM source files on Scala 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
zainab-ali committed Sep 27, 2023
1 parent d56f070 commit 32babd7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/core/src-scala-3/SourceLocationMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package weaver
// format: off

import scala.quoted._
import java.nio.file.Paths

trait SourceLocationMacro {
trait Here {
Expand All @@ -25,7 +26,7 @@ object macros {

val position = Position.ofMacroExpansion

val psj = position.sourceFile.getJPath.get
val psj = position.sourceFile.getJPath.getOrElse(Paths.get(position.sourceFile.path))
// Comparing roots to workaround a Windows-specific behaviour
// https://github.com/disneystreaming/weaver-test/issues/364
val rp = if(pwd.getRoot == psj.getRoot) Expr(pwd.relativize(psj).toString) else Expr(psj.toString)
Expand Down

0 comments on commit 32babd7

Please sign in to comment.