File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -168,11 +168,14 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
168168 val cause = ite.getCause match
169169 case e : ExceptionInInitializerError => e.getCause
170170 case e => e
171- def isWrapperCode (ste : StackTraceElement ) =
172- ste.getClassName == d.symbol.owner.name.show
171+ // detect
172+ // at repl$.rs$line$2$.<clinit>(rs$line$2:1)
173+ // at repl$.rs$line$2.res1(rs$line$2)
174+ def isWrapperInitialization (ste : StackTraceElement ) =
175+ ste.getClassName.startsWith(nme.REPL_PACKAGE .toString + " ." ) // d.symbol.owner.name.show is simple name
173176 && (ste.getMethodName == nme.STATIC_CONSTRUCTOR .show || ste.getMethodName == nme.CONSTRUCTOR .show)
174177
175- cause.formatStackTracePrefix(! isWrapperCode (_))
178+ cause.formatStackTracePrefix(! isWrapperInitialization (_))
176179 end renderError
177180
178181 private def infoDiagnostic (msg : String , d : Denotation )(using Context ): Diagnostic =
Original file line number Diff line number Diff line change @@ -219,6 +219,17 @@ class ReplCompilerTests extends ReplTest {
219219 run(" val (x: 1) = 2" )
220220 assertEquals(" scala.MatchError: 2 (of class java.lang.Integer)" , storedOutput().linesIterator.next())
221221 }
222+ @ Test def `i12920 must truncate stack trace to user code` = fromInitialState { implicit state =>
223+ run(" ???" )
224+ val all = lines()
225+ assertEquals(3 , all.length)
226+ assertEquals(" scala.NotImplementedError: an implementation is missing" , all.head)
227+ /* avoid asserting much about line number or elided count
228+ scala.NotImplementedError: an implementation is missing
229+ at scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
230+ ... 28 elided
231+ */
232+ }
222233}
223234
224235object ReplCompilerTests {
You can’t perform that action at this time.
0 commit comments