-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message for mismatched tasty versions, allow configuration of header unpickler #18828
Changes from all commits
d19d054
a6c5b17
67351cb
7993b29
88dd1ca
02ec718
df4da02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,7 +24,8 @@ import ast.desugar | |||||
|
||||||
import parsing.JavaParsers.OutlineJavaParser | ||||||
import parsing.Parsers.OutlineParser | ||||||
import dotty.tools.tasty.TastyHeaderUnpickler | ||||||
import dotty.tools.tasty.{TastyHeaderUnpickler, UnpickleException, UnpicklerConfig} | ||||||
import dotty.tools.dotc.core.tasty.TastyUnpickler | ||||||
|
||||||
|
||||||
object SymbolLoaders { | ||||||
|
@@ -421,22 +422,33 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader { | |||||
def description(using Context): String = "TASTy file " + tastyFile.toString | ||||||
|
||||||
override def doComplete(root: SymDenotation)(using Context): Unit = | ||||||
val (classRoot, moduleRoot) = rootDenots(root.asClass) | ||||||
val tastyBytes = tastyFile.toByteArray | ||||||
val unpickler = new tasty.DottyUnpickler(tastyBytes) | ||||||
unpickler.enter(roots = Set(classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource)) | ||||||
if mayLoadTreesFromTasty then | ||||||
classRoot.classSymbol.rootTreeOrProvider = unpickler | ||||||
moduleRoot.classSymbol.rootTreeOrProvider = unpickler | ||||||
checkTastyUUID(tastyFile, tastyBytes) | ||||||
try | ||||||
val (classRoot, moduleRoot) = rootDenots(root.asClass) | ||||||
val tastyBytes = tastyFile.toByteArray | ||||||
val unpickler = new tasty.DottyUnpickler(tastyBytes) | ||||||
unpickler.enter(roots = Set(classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource)) | ||||||
if mayLoadTreesFromTasty then | ||||||
classRoot.classSymbol.rootTreeOrProvider = unpickler | ||||||
moduleRoot.classSymbol.rootTreeOrProvider = unpickler | ||||||
checkTastyUUID(tastyFile, tastyBytes) | ||||||
catch case e: RuntimeException => | ||||||
val message = e match | ||||||
case e: UnpickleException => | ||||||
i"""TASTy file ${tastyFile.canonicalPath} could not be read, failing with: | ||||||
| ${Option(e.getMessage).getOrElse("")}""" | ||||||
case _ => | ||||||
i"""TASTy file ${tastyFile.canonicalPath} is broken, reading aborted with ${e.getClass} | ||||||
| ${Option(e.getMessage).getOrElse("")}""" | ||||||
if (ctx.debug) e.printStackTrace() | ||||||
throw IOException(message) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep the cause, here:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ClassfileParser also does not keep the cause There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meh ... OK. |
||||||
|
||||||
|
||||||
private def checkTastyUUID(tastyFile: AbstractFile, tastyBytes: Array[Byte])(using Context): Unit = | ||||||
val classfile = | ||||||
val className = tastyFile.name.stripSuffix(".tasty") | ||||||
tastyFile.resolveSibling(className + ".class") | ||||||
if classfile != null then | ||||||
val tastyUUID = new TastyHeaderUnpickler(tastyBytes).readHeader() | ||||||
val tastyUUID = new TastyHeaderUnpickler(TastyUnpickler.scala3CompilerConfig, tastyBytes).readHeader() | ||||||
new ClassfileTastyUUIDParser(classfile)(ctx).checkTastyUUID(tastyUUID) | ||||||
else | ||||||
// This will be the case in any of our tests that compile with `-Youtput-only-tasty` | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
RuntimeException
and notException
orNonFatal
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its what the ClassfileParser does, i.e. what TASTy unpicking used to do before we did the TASTy-first classpath change