@@ -24,7 +24,7 @@ import ast.desugar
24
24
25
25
import parsing .JavaParsers .OutlineJavaParser
26
26
import parsing .Parsers .OutlineParser
27
- import dotty .tools .tasty .TastyHeaderUnpickler
27
+ import dotty .tools .tasty .{ TastyHeaderUnpickler , UnpickleException }
28
28
29
29
30
30
object SymbolLoaders {
@@ -421,14 +421,25 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
421
421
def description (using Context ): String = " TASTy file " + tastyFile.toString
422
422
423
423
override def doComplete (root : SymDenotation )(using Context ): Unit =
424
- val (classRoot, moduleRoot) = rootDenots(root.asClass)
425
- val tastyBytes = tastyFile.toByteArray
426
- val unpickler = new tasty.DottyUnpickler (tastyBytes)
427
- unpickler.enter(roots = Set (classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource ))
428
- if mayLoadTreesFromTasty then
429
- classRoot.classSymbol.rootTreeOrProvider = unpickler
430
- moduleRoot.classSymbol.rootTreeOrProvider = unpickler
431
- checkTastyUUID(tastyFile, tastyBytes)
424
+ try
425
+ val (classRoot, moduleRoot) = rootDenots(root.asClass)
426
+ val tastyBytes = tastyFile.toByteArray
427
+ val unpickler = new tasty.DottyUnpickler (tastyBytes)
428
+ unpickler.enter(roots = Set (classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource ))
429
+ if mayLoadTreesFromTasty then
430
+ classRoot.classSymbol.rootTreeOrProvider = unpickler
431
+ moduleRoot.classSymbol.rootTreeOrProvider = unpickler
432
+ checkTastyUUID(tastyFile, tastyBytes)
433
+ catch case e : RuntimeException =>
434
+ val message = e match
435
+ case e : UnpickleException =>
436
+ i """ TASTy file ${tastyFile.canonicalPath} could not be read, failing with:
437
+ | ${Option (e.getMessage).getOrElse(" " )}"""
438
+ case _ =>
439
+ i """ TASTy file ${tastyFile.canonicalPath} is broken, reading aborted with ${e.getClass}
440
+ | ${Option (e.getMessage).getOrElse(" " )}"""
441
+ if (ctx.debug) e.printStackTrace()
442
+ throw IOException (message)
432
443
433
444
434
445
private def checkTastyUUID (tastyFile : AbstractFile , tastyBytes : Array [Byte ])(using Context ): Unit =
0 commit comments