Skip to content

Commit

Permalink
Change ComponentTreeDepsIrCreator to use linked set to preserve order…
Browse files Browse the repository at this point in the history
…ing of @ComponentTreeDeps.aggregatedDeps.

Fixes #3006

RELNOTES=Fixes #3006:Change mutable set to linked set to preserve well defined ordering.
PiperOrigin-RevId: 408991462
  • Loading branch information
bcorso authored and Dagger Team committed Nov 10, 2021
1 parent 2fa9aa7 commit bf5bb46
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -133,10 +133,10 @@ class ComponentTreeDepsIrCreator private constructor(
val globalEntryPointsByComponent = aggregatedDeps
.filter { it.test == null && it.module == null }
.groupBy(keySelector = { it.test }, valueTransform = { it.fqName })
val result = mutableMapOf<ClassName, MutableSet<ClassName>>()
val result = mutableMapOf<ClassName, LinkedHashSet<ClassName>>()
aggregatedRoots.forEach { aggregatedRoot ->
if (!rootsUsingSharedComponent.contains(aggregatedRoot.root)) {
result.getOrPut(aggregatedRoot.root) { mutableSetOf() }.apply {
result.getOrPut(aggregatedRoot.root) { linkedSetOf() }.apply {
addAll(globalModules)
addAll(globalEntryPointsByComponent.values.flatten())
addAll(testDepsByRoot.getOrElse(aggregatedRoot.root) { emptyList() })
Expand All @@ -145,13 +145,13 @@ class ComponentTreeDepsIrCreator private constructor(
}
// Add the Default/EarlyEntryPoint root if necessary.
if (rootsUsingSharedComponent.isNotEmpty()) {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { mutableSetOf() }.apply {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { linkedSetOf() }.apply {
addAll(globalModules)
addAll(globalEntryPointsByComponent.values.flatten())
addAll(rootsUsingSharedComponent.flatMap { testDepsByRoot.getOrElse(it) { emptyList() } })
}
} else if (hasEarlyEntryPoints) {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { mutableSetOf() }.apply {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { linkedSetOf() }.apply {
addAll(globalModules)
addAll(
globalEntryPointsByComponent.entries
Expand Down

0 comments on commit bf5bb46

Please sign in to comment.