Skip to content

Commit

Permalink
Merge pull request #702 from zainab-ali/fix-source-location-macro-non…
Browse files Browse the repository at this point in the history
…-jvm-source-files

Get source location for non-JVM source files on Scala 3.
  • Loading branch information
Baccata committed Sep 27, 2023
2 parents d56f070 + 10356e2 commit 282c18d
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 282c18d

Please sign in to comment.