com-lihaoyi / sourcecode

Scala library providing "source" metadata to your program, similar to Python's __name__, C++'s __LINE__ or Ruby's __FILE__.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullPointerException when source file does not exist (e.g. in mdoc)

TomasMikula opened this issue · comments

Hi,

when trying to use sourcecode in an mdoc snippet, NullPointerException is thrown.

Mdoc input:

```scala mdoc
implicitly[sourcecode.File]
```

Error:

java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.toAbsolutePath()" because the return value of "scala.quoted.Quotes$reflectModule$SourceFileMethods.jpath(Object)" is null
	at sourcecode.Macros$.fileImpl(Macros.scala:150)

Would it be possible to return something like File("<none>") instead?