File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -142,11 +142,15 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
142
142
143
143
/** Force module initialization in the absence of members. */
144
144
def forceModule (sym : Symbol )(using Context ): Seq [Diagnostic ] =
145
+ import scala .util .control .NonFatal
145
146
def load () =
146
147
val objectName = sym.fullName.encode.toString
147
148
Class .forName(objectName, true , classLoader())
148
149
Nil
149
- try load() catch case e : ExceptionInInitializerError => List (renderError(e, sym.denot))
150
+ try load()
151
+ catch
152
+ case e : ExceptionInInitializerError => List (renderError(e, sym.denot))
153
+ case NonFatal (e) => List (renderError(InvocationTargetException (e), sym.denot))
150
154
151
155
/** Render the stack trace of the underlying exception. */
152
156
def renderError (ite : InvocationTargetException | ExceptionInInitializerError , d : Denotation )(using Context ): Diagnostic =
Original file line number Diff line number Diff line change @@ -334,6 +334,19 @@ class ReplCompilerTests extends ReplTest:
334
334
assertEquals(" scala.MatchError: hi (of class java.lang.String)" , all.head)
335
335
}
336
336
337
+ @ Test def i14701 = initially {
338
+ val state = run(" val _ = ???" )
339
+ val all = lines()
340
+ assertEquals(3 , all.length)
341
+ assertEquals(" scala.NotImplementedError: an implementation is missing" , all.head)
342
+ state
343
+ } andThen {
344
+ run(" val _ = assert(false)" )
345
+ val all = lines()
346
+ assertEquals(3 , all.length)
347
+ assertEquals(" java.lang.AssertionError: assertion failed" , all.head)
348
+ }
349
+
337
350
@ Test def i14491 =
338
351
initially {
339
352
run(" import language.experimental.fewerBraces" )
You can’t perform that action at this time.
0 commit comments