File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 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(""):
2626 || (cyclicErrors != noPrinter && this .isInstanceOf [CyclicReference ] && ! (ctx.mode is Mode .CheckCyclic ))
2727 || ctx.settings.YdebugTypeError .value
2828 || ctx.settings.YdebugError .value
29+ || ctx.settings.YdebugUnpickling .value
2930
3031 override def fillInStackTrace (): Throwable =
3132 if computeStackTrace then super .fillInStackTrace().nn
@@ -191,3 +192,14 @@ object CyclicReference:
191192 ex
192193end CyclicReference
193194
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,
145145 def where =
146146 val f = denot.symbol.associatedFile
147147 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)
154149 treeAtAddr(currentAddr) =
155150 try
156151 atPhaseBeforeTransforms {
You can’t perform that action at this time.
0 commit comments