@@ -14,7 +14,7 @@ import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
14
14
import Contexts ._ , Symbols ._ , Flags ._ , SymDenotations ._ , Types ._ , Scopes ._ , Names ._
15
15
import NameOps ._
16
16
import StdNames ._
17
- import classfile .ClassfileParser
17
+ import classfile .{ ClassfileParser , ClassfileTastyUUIDParser }
18
18
import Decorators ._
19
19
20
20
import util .Stats
@@ -24,6 +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
28
28
29
29
30
object SymbolLoaders {
@@ -421,14 +422,25 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
421
422
422
423
override def doComplete (root : SymDenotation )(using Context ): Unit =
423
424
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)
427
427
unpickler.enter(roots = Set (classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource ))
428
428
if mayLoadTreesFromTasty then
429
429
classRoot.classSymbol.rootTreeOrProvider = unpickler
430
430
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 " )
432
444
433
445
private def mayLoadTreesFromTasty (using Context ): Boolean =
434
446
ctx.settings.YretainTrees .value || ctx.settings.fromTasty.value
0 commit comments