From 71ce7ec006e57eae1b916ed9c95b0e4cb9d7a0ae Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 23 Aug 2018 01:43:41 +0900 Subject: [PATCH] [bport] Fix the extraHash used when reading a V1 file This backports #581 which fixes an issue introduced in #542, the fix wasn't backported when #542 itself was backported in #599. Setting extraHash to apiHash is not safe because in IncrementalNameHashing#sameAPI an error is emitted if the extra hashes are different and the class is not a trait. Setting it to 0 should be safe since that's the value used for things which are not traits. --- .../sbt/internal/inc/binary/converters/ProtobufReaders.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/binary/converters/ProtobufReaders.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/binary/converters/ProtobufReaders.scala index b38aa61c3b..96b3a379dc 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/binary/converters/ProtobufReaders.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/binary/converters/ProtobufReaders.scala @@ -542,8 +542,8 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: schema.Version) val name = analyzedClass.name val api = mkLazy(analyzedClass.api.read(fromCompanions, ExpectedCompanionsInAnalyzedClass)) val apiHash = analyzedClass.apiHash - // Default on api hash to avoid issues when comparing hashes from two different analysis formats - val extraHash = if (currentVersion == schema.Version.V1) apiHash else analyzedClass.extraHash + // Default to 0 to avoid issues when comparing hashes from two different analysis formats + val extraHash = if (currentVersion == schema.Version.V1) 0 else analyzedClass.extraHash val nameHashes = analyzedClass.nameHashes.toZincArray(fromNameHash) val hasMacro = analyzedClass.hasMacro AnalyzedClass.of(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash)