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 @@ -167,11 +167,14 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
167167 val cause = ite.getCause match
168168 case e : ExceptionInInitializerError => e.getCause
169169 case e => e
170- def isWrapperCode (ste : StackTraceElement ) =
171- ste.getClassName == d.symbol.owner.name.show
170+ // detect
171+ // at repl$.rs$line$2$.<clinit>(rs$line$2:1)
172+ // at repl$.rs$line$2.res1(rs$line$2)
173+ def isWrapperInitialization (ste : StackTraceElement ) =
174+ ste.getClassName.startsWith(nme.REPL_PACKAGE .toString + " ." ) // d.symbol.owner.name.show is simple name
172175 && (ste.getMethodName == nme.STATIC_CONSTRUCTOR .show || ste.getMethodName == nme.CONSTRUCTOR .show)
173176
174- cause.formatStackTracePrefix(! isWrapperCode (_))
177+ cause.formatStackTracePrefix(! isWrapperInitialization (_))
175178 end renderError
176179
177180 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