File tree 2 files changed +13
-6
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ abstract class TypeError(using creationContext: Context) extends Exception(""):
26
26
|| (cyclicErrors != noPrinter && this .isInstanceOf [CyclicReference ] && ! (ctx.mode is Mode .CheckCyclic ))
27
27
|| ctx.settings.YdebugTypeError .value
28
28
|| ctx.settings.YdebugError .value
29
+ || ctx.settings.YdebugUnpickling .value
29
30
30
31
override def fillInStackTrace (): Throwable =
31
32
if computeStackTrace then super .fillInStackTrace().nn
@@ -191,3 +192,14 @@ object CyclicReference:
191
192
ex
192
193
end CyclicReference
193
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 @@ -145,12 +145,7 @@ class TreeUnpickler(reader: TastyReader,
145
145
def where =
146
146
val f = denot.symbol.associatedFile
147
147
if f == null then " " else s " in $f"
148
- if ctx.settings.YdebugUnpickling .value then throw ex
149
- else throw TypeError (
150
- em """ Could not read definition of $denot$where
151
- |An exception was encountered:
152
- | $ex
153
- |Run with -Ydebug-unpickling to see full stack trace. """ )
148
+ throw UnpicklingError (denot, where, ex)
154
149
treeAtAddr(currentAddr) =
155
150
try
156
151
atPhaseBeforeTransforms {
You can’t perform that action at this time.
0 commit comments