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 @@ -168,11 +168,14 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
168
168
val cause = ite.getCause match
169
169
case e : ExceptionInInitializerError => e.getCause
170
170
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
173
176
&& (ste.getMethodName == nme.STATIC_CONSTRUCTOR .show || ste.getMethodName == nme.CONSTRUCTOR .show)
174
177
175
- cause.formatStackTracePrefix(! isWrapperCode (_))
178
+ cause.formatStackTracePrefix(! isWrapperInitialization (_))
176
179
end renderError
177
180
178
181
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