@@ -14,7 +14,7 @@ import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
1414import Contexts ._ , Symbols ._ , Flags ._ , SymDenotations ._ , Types ._ , Scopes ._ , Names ._
1515import NameOps ._
1616import StdNames ._
17- import classfile .ClassfileParser
17+ import classfile .{ ClassfileParser , ClassfileTastyUUIDParser }
1818import Decorators ._
1919
2020import util .Stats
@@ -24,6 +24,7 @@ import ast.desugar
2424
2525import parsing .JavaParsers .OutlineJavaParser
2626import parsing .Parsers .OutlineParser
27+ import dotty .tools .tasty .TastyHeaderUnpickler
2728
2829
2930object SymbolLoaders {
@@ -421,14 +422,25 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
421422
422423 override def doComplete (root : SymDenotation )(using Context ): Unit =
423424 val (classRoot, moduleRoot) = rootDenots(root.asClass)
424- val unpickler =
425- val tastyBytes = tastyFile.toByteArray
426- new tasty.DottyUnpickler (tastyBytes)
425+ val tastyBytes = tastyFile.toByteArray
426+ val unpickler = new tasty.DottyUnpickler (tastyBytes)
427427 unpickler.enter(roots = Set (classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource ))
428428 if mayLoadTreesFromTasty then
429429 classRoot.classSymbol.rootTreeOrProvider = unpickler
430430 moduleRoot.classSymbol.rootTreeOrProvider = unpickler
431- // TODO check TASTy UUID matches classfile
431+ checkTastyUUID(tastyFile, tastyBytes)
432+
433+
434+ private def checkTastyUUID (tastyFile : AbstractFile , tastyBytes : Array [Byte ])(using Context ): Unit =
435+ var classfile = tastyFile.resolveSibling(tastyFile.name.stripSuffix(" .tasty" ) + " .class" )
436+ if classfile == null then
437+ classfile = tastyFile.resolveSibling(tastyFile.name.stripSuffix(" .tasty" ) + " $.class" )
438+ if classfile != null then
439+ val tastyUUID = new TastyHeaderUnpickler (tastyBytes).readHeader()
440+ new ClassfileTastyUUIDParser (classfile)(ctx).checkTastyUUID(tastyUUID)
441+ else
442+ // This will be the case in any of our tests that compile with `-Youtput-only-tasty`
443+ report.inform(s " No classfiles found for $tastyFile when checking TASTy UUID " )
432444
433445 private def mayLoadTreesFromTasty (using Context ): Boolean =
434446 ctx.settings.YretainTrees .value || ctx.settings.fromTasty.value
0 commit comments