File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 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) {
142142
143143 /** Force module initialization in the absence of members. */
144144 def forceModule (sym : Symbol )(using Context ): Seq [Diagnostic ] =
145+ import scala .util .control .NonFatal
145146 def load () =
146147 val objectName = sym.fullName.encode.toString
147148 Class .forName(objectName, true , classLoader())
148149 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))
150154
151155 /** Render the stack trace of the underlying exception. */
152156 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:
334334 assertEquals(" scala.MatchError: hi (of class java.lang.String)" , all.head)
335335 }
336336
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+
337350 @ Test def i14491 =
338351 initially {
339352 run(" import language.experimental.fewerBraces" )
You can’t perform that action at this time.
0 commit comments