From 8b01f72b28dc4ef8f6ec7dea5f722c95ca1438a5 Mon Sep 17 00:00:00 2001 From: friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:47:25 -0700 Subject: [PATCH 1/3] Handle DependencyByMacroExpansion during serialization --- .../inc/consistent/ConsistentAnalysisFormat.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala index b6bb03a01..bf8431158 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala @@ -344,6 +344,8 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { wrS("inheritance.external", rs.inheritance.external) wrS("localInheritance.internal", rs.localInheritance.internal) wrS("localInheritance.external", rs.localInheritance.external) + wrS("macroExpansion.internal", rs.macroExpansion.internal) + wrS("macroExpansion.external", rs.macroExpansion.external) wrS("productClassNames", rs.productClassName) } @@ -367,23 +369,25 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { val bin = rd(mapSource, mapBinary) val lcn = rd(mapBinary, identity[String]) val cn = rd(mapSource, identity[String]) - val mri, mre, ii, ie, lii, lie, bcn = rdS() + val mri, mre, ii, ie, lii, lie, mei, mee, bcn = rdS() def deps( m: Relation[String, String], i: Relation[String, String], - l: Relation[String, String] + l: Relation[String, String], + me: Relation[String, String], ) = Map( DependencyContext.DependencyByMemberRef -> m, DependencyContext.DependencyByInheritance -> i, - DependencyContext.LocalDependencyByInheritance -> l + DependencyContext.LocalDependencyByInheritance -> l, + DependencyContext.DependencyByMacroExpansion -> me, ) Relations.make( p, bin, lcn, - InternalDependencies(deps(mri, ii, lii)), - ExternalDependencies(deps(mre, ie, lie)), + InternalDependencies(deps(mri, ii, lii, mei)), + ExternalDependencies(deps(mre, ie, lie, mee)), cn, un, bcn From 6dd9e692bdec22833245dfa9158f379b3bc95bb5 Mon Sep 17 00:00:00 2001 From: friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Sat, 5 Oct 2024 23:02:07 -0700 Subject: [PATCH 2/3] Serialize & deserialize extraHash --- .../internal/inc/consistent/ConsistentAnalysisFormat.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala index bf8431158..73d5fd203 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala @@ -142,6 +142,7 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { out.int(ac.apiHash()) out.bool(ac.hasMacro) out.string(ac.provenance()) + out.int(ac.extraHash()) val nh0 = ac.nameHashes() val nh = if (nh0.length > 1 && sort) { val nh = nh0.clone() @@ -166,6 +167,7 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { val ah = in.int() val hm = in.bool() val p = in.string() + val eh = in.int() val nhNames = in.readStringArray() val nhScopes = in.readArray[UseScope]() { UseScope.values()(in.byte().toInt) } val nhHashes = in.readArray[Int]() { in.int() } @@ -178,7 +180,7 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { val comp = if (storeApis) Companions.of(readClassLike(in), readClassLike(in)) else APIs.emptyCompanions - AnalyzedClass.of(ts, name, SafeLazyProxy.strict(comp), ah, nameHashes, hm, ah, p) + AnalyzedClass.of(ts, name, SafeLazyProxy.strict(comp), ah, nameHashes, hm, eh, p) } } From 53d55a71d7ea3a560a53781fb7159fcfb2ec6931 Mon Sep 17 00:00:00 2001 From: friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:47:57 -0700 Subject: [PATCH 3/3] Add test --- .../src/test/scala/sbt/inc/AnalysisGenerators.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala b/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala index d338ee712..f73696eb6 100644 --- a/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala +++ b/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala @@ -206,18 +206,21 @@ object AnalysisGenerators { memberRef <- genRClassDependencies(classNames) inheritance <- genSubRClassDependencies(memberRef) localInheritance <- genSubRClassDependencies(memberRef) + macroExpansion <- genSubRClassDependencies(memberRef) internal <- InternalDependencies( Map( DependencyByMemberRef -> memberRef.internal, DependencyByInheritance -> inheritance.internal, - LocalDependencyByInheritance -> localInheritance.internal + LocalDependencyByInheritance -> localInheritance.internal, + DependencyByMacroExpansion -> macroExpansion.internal, ) ) external <- ExternalDependencies( Map( DependencyByMemberRef -> memberRef.external, DependencyByInheritance -> inheritance.external, - LocalDependencyByInheritance -> localInheritance.external + LocalDependencyByInheritance -> localInheritance.external, + DependencyByMacroExpansion -> macroExpansion.external, ) ) classes = rel(srcs, classNames)