From 10356e2e81f815e8454a42a70247e3e59472a638 Mon Sep 17 00:00:00 2001 From: zainab-ali Date: Wed, 27 Sep 2023 14:25:06 +0100 Subject: [PATCH] Get source location for non-JVM source files on Scala 3. --- modules/core/src-scala-3/SourceLocationMacro.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/src-scala-3/SourceLocationMacro.scala b/modules/core/src-scala-3/SourceLocationMacro.scala index f604f6ac..9eb1258a 100644 --- a/modules/core/src-scala-3/SourceLocationMacro.scala +++ b/modules/core/src-scala-3/SourceLocationMacro.scala @@ -4,6 +4,7 @@ package weaver // format: off import scala.quoted._ +import java.nio.file.Paths trait SourceLocationMacro { trait Here { @@ -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)