File tree Expand file tree Collapse file tree 7 files changed +51
-2
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 7 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -372,8 +372,11 @@ object Splicer {
372372 private object MissingClassDefinedInCurrentRun {
373373 def unapply (targetException : NoClassDefFoundError )(given ctx : Context ): Option [Symbol ] = {
374374 val className = targetException.getMessage
375- val sym = ctx.base.staticRef(className.toTypeName).symbol
376- if (sym.isDefinedInCurrentRun) Some (sym) else None
375+ if (className eq null ) None
376+ else {
377+ val sym = ctx.base.staticRef(className.toTypeName).symbol
378+ if (sym.isDefinedInCurrentRun) Some (sym) else None
379+ }
377380 }
378381 }
379382
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg-macros/macro-class-not-found-1/Bar.scala:4:13 ------------------------------------------------------
2+ 4 | Foo.myMacro() // error
3+ | ^^^^^^^^^^^^^
4+ | Exception occurred while executing macro expansion.
5+ | java.lang.NoClassDefFoundError
6+ | at Foo$.aMacroImplementation(Foo.scala:8)
7+ |
8+ | This location is in code that was inlined at Bar.scala:4
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+
3+ object Bar {
4+ Foo .myMacro() // error
5+ }
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+
3+ object Foo {
4+
5+ inline def myMacro (): Unit = $ { aMacroImplementation }
6+
7+ def aMacroImplementation (given QuoteContext ): Expr [Unit ] =
8+ throw new NoClassDefFoundError ()
9+
10+ }
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg-macros/macro-class-not-found-2/Bar.scala:4:13 ------------------------------------------------------
2+ 4 | Foo.myMacro() // error
3+ | ^^^^^^^^^^^^^
4+ | Exception occurred while executing macro expansion.
5+ | java.lang.NoClassDefFoundError: this.is.not.a.Class
6+ | at Foo$.aMacroImplementation(Foo.scala:8)
7+ |
8+ | This location is in code that was inlined at Bar.scala:4
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+
3+ object Bar {
4+ Foo .myMacro() // error
5+ }
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+
3+ object Foo {
4+
5+ inline def myMacro (): Unit = $ { aMacroImplementation }
6+
7+ def aMacroImplementation (given QuoteContext ): Expr [Unit ] =
8+ throw new NoClassDefFoundError (" this.is.not.a.Class" )
9+
10+ }
You can’t perform that action at this time.
0 commit comments