From 52fdc7ae292616998db8510c3335606558a4ceb7 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Tue, 18 Jun 2024 19:48:38 +0200 Subject: [PATCH] bugfix: Fix location macro if using virtual files --- .../shared/src/main/scala-3/munit/internal/MacroCompat.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/munit/shared/src/main/scala-3/munit/internal/MacroCompat.scala b/munit/shared/src/main/scala-3/munit/internal/MacroCompat.scala index 1e5b3ce3..89835813 100644 --- a/munit/shared/src/main/scala-3/munit/internal/MacroCompat.scala +++ b/munit/shared/src/main/scala-3/munit/internal/MacroCompat.scala @@ -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) }) } }