scalameta / munit

Scala testing library with actionable errors and extensible APIs
https://scalameta.org/munit
Apache License 2.0
428 stars 88 forks source link

Location macro throws NPE for in-memory (virtual) source files #795

Closed vasilmkd closed 2 months ago

vasilmkd commented 2 months ago

Please read https://github.com/scala/scala3/issues/20591 for the whole context.

Expanding the Location macro for in-memory source files throws a NullPointerException.

Exception occurred while executing macro expansion. java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.toString()" because the return value of "scala.quoted.Quotes$reflectModule$SourceFileMethods.jpath(Object)" is null at munit.internal.MacroCompat$.locationImpl(MacroCompat.scala:18)

At the moment, this macro is written exactly the same as in the Scala 3 documentation.

Most likely, the macro implementation will have to be adjusted, for maximum compatibility.

vasilmkd commented 2 months ago

Here is a local reproduction of the issue.

https://github.com/scala/scala3/issues/20591#issuecomment-2176082500