Closed
Description
jpath
in https://github.com/lampepfl/dotty/blob/147e9baf778a24f9f363ecf8e3898d69c40421ee/library/src/scala/quoted/Quotes.scala#L4154-L4155 is implemented as self.file.jpath
which can be null (for example when using the REPL because file
will be a VirtualFile).
We should update the API documentation to mention this fact, but I think it'd be even better to deprecate this method and replace it by a method that returns an Option, this would avoid mistakes like https://github.com/scalatest/scalatest/blob/e6e656bac6e54be2a9ae4f286a3727714ac09d1e/dotty/core/src/main/scala/org/scalatest/AssertionsMacro.scala#L53 which lead to the scalatest assert macro throwing an NPE from the REPL:
$ cs launch scala3-repl:3.0.0 -- -classpath "$(cs fetch -p org.scalatest:scalatest_3:3.2.9)"
scala> org.scalatest.Assertions.assert(List(3, 2, 1).sorted == List(1, 2, 3))
1 |org.scalatest.Assertions.assert(List(3, 2, 1).sorted == List(1, 2, 3))
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|Exception occurred while executing macro expansion.
|java.lang.NullPointerException
| at org.scalatest.AssertionsMacro$.transform(AssertionsMacro.scala:53)
| at org.scalatest.AssertionsMacro$.assert(AssertionsMacro.scala:33)
|
| This location contains code that was inlined from rs$line$4:1