@@ -11,7 +11,7 @@ import dotc.core.Denotations.Denotation
11
11
import dotc .core .Flags
12
12
import dotc .core .Flags ._
13
13
import dotc .core .Symbols .{Symbol , defn }
14
- import dotc .core .StdNames .str
14
+ import dotc .core .StdNames .{ nme , str }
15
15
import dotc .core .NameOps ._
16
16
import dotc .printing .ReplPrinter
17
17
import dotc .reporting .{MessageRendering , Message , Diagnostic }
@@ -120,20 +120,22 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
120
120
if (d.symbol.is(Flags .Lazy )) Some (infoDiagnostic(dcl, d))
121
121
else valueOf(d.symbol).map(value => infoDiagnostic(s " $dcl = $value" , d))
122
122
}
123
- catch { case ex : InvocationTargetException => Some (infoDiagnostic(renderError(ex), d)) }
123
+ catch { case ex : InvocationTargetException => Some (infoDiagnostic(renderError(ex, d ), d)) }
124
124
}
125
125
126
- /** Render the stack trace of the underlying exception */
127
- private def renderError (ex : InvocationTargetException ): String = {
128
- val cause = ex.getCause match {
126
+ /** Render the stack trace of the underlying exception. */
127
+ private def renderError (ite : InvocationTargetException , d : Denotation )(using Context ): String =
128
+ import dotty .tools .dotc .util .StackTraceOps ._
129
+ val cause = ite.getCause match {
129
130
case ex : ExceptionInInitializerError => ex.getCause
130
131
case ex => ex
131
132
}
132
- val sw = new StringWriter ()
133
- val pw = new PrintWriter (sw)
134
- cause.printStackTrace(pw)
135
- sw.toString
136
- }
133
+ def isWrapperCode (ste : StackTraceElement ) =
134
+ ste.getClassName == d.symbol.owner.name.show
135
+ && (ste.getMethodName == nme.STATIC_CONSTRUCTOR .show || ste.getMethodName == nme.CONSTRUCTOR .show)
136
+
137
+ cause.formatStackTracePrefix(! isWrapperCode(_))
138
+ end renderError
137
139
138
140
private def infoDiagnostic (msg : String , d : Denotation )(using Context ): Diagnostic =
139
141
new Diagnostic .Info (msg, d.symbol.sourcePos)
0 commit comments