File tree 2 files changed +17
-3
lines changed
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) {
167
167
val cause = ite.getCause match
168
168
case e : ExceptionInInitializerError => e.getCause
169
169
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
172
175
&& (ste.getMethodName == nme.STATIC_CONSTRUCTOR .show || ste.getMethodName == nme.CONSTRUCTOR .show)
173
176
174
- cause.formatStackTracePrefix(! isWrapperCode (_))
177
+ cause.formatStackTracePrefix(! isWrapperInitialization (_))
175
178
end renderError
176
179
177
180
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 {
219
219
run(" val (x: 1) = 2" )
220
220
assertEquals(" scala.MatchError: 2 (of class java.lang.Integer)" , storedOutput().linesIterator.next())
221
221
}
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
+ }
222
233
}
223
234
224
235
object ReplCompilerTests {
You can’t perform that action at this time.
0 commit comments