File tree 2 files changed +17
-7
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ abstract class TypeError(using creationContext: Context) extends Exception(""):
22
22
* This is expensive and only useful for debugging purposes.
23
23
*/
24
24
def computeStackTrace : Boolean =
25
- ctx.debug || (cyclicErrors != noPrinter && this .isInstanceOf [CyclicReference ] && ! (ctx.mode is Mode .CheckCyclic ))
25
+ ctx.debug
26
+ || (cyclicErrors != noPrinter && this .isInstanceOf [CyclicReference ] && ! (ctx.mode is Mode .CheckCyclic ))
27
+ || ctx.settings.YdebugTypeError .value
28
+ || ctx.settings.YdebugError .value
29
+ || ctx.settings.YdebugUnpickling .value
26
30
27
31
override def fillInStackTrace (): Throwable =
28
32
if computeStackTrace then super .fillInStackTrace().nn
@@ -188,3 +192,14 @@ object CyclicReference:
188
192
ex
189
193
end CyclicReference
190
194
195
+ class UnpicklingError (denot : Denotation , where : String , cause : Throwable )(using Context ) extends TypeError :
196
+ override def toMessage (using Context ): Message =
197
+ val debugUnpickling = cause match
198
+ case cause : UnpicklingError => " "
199
+ case _ =>
200
+ if ctx.settings.YdebugUnpickling .value then
201
+ cause.getStackTrace().nn.mkString(" \n " , " \n " , " " )
202
+ else " \n\n Run with -Ydebug-unpickling to see full stack trace."
203
+ em """ Could not read definition $denot$where. Caused by the following exception:
204
+ | $cause$debugUnpickling"""
205
+ end UnpicklingError
Original file line number Diff line number Diff line change @@ -128,12 +128,7 @@ class TreeUnpickler(reader: TastyReader,
128
128
def where =
129
129
val f = denot.symbol.associatedFile
130
130
if f == null then " " else s " in $f"
131
- if ctx.settings.YdebugUnpickling .value then throw ex
132
- else throw TypeError (
133
- em """ Could not read definition of $denot$where
134
- |An exception was encountered:
135
- | $ex
136
- |Run with -Ydebug-unpickling to see full stack trace. """ )
131
+ throw UnpicklingError (denot, where, ex)
137
132
treeAtAddr(currentAddr) =
138
133
try
139
134
atPhaseBeforeTransforms {
You can’t perform that action at this time.
0 commit comments