Skip to content

Commit 41a1009

Browse files
Fix models comparison in Spring variable constructor #2104 (#2151)
1 parent e0d34d6 commit 41a1009

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgSpringVariableConstructor.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ class CgSpringVariableConstructor(context: CgContext) : CgVariableConstructor(co
4141
return super.getOrCreateVariable(model, name)
4242
}
4343

44-
private fun findCgValueByModel(model: UtModel, modelToValueMap: Map<Set<UtModel>, CgValue>): CgValue? =
44+
private fun findCgValueByModel(modelToFind: UtModel, modelToValueMap: Map<Set<UtModel>, CgValue>): CgValue? =
45+
// Here we really need to compare models by reference.
46+
// Standard equals is not appropriate because two models from different execution may have same `id`.
47+
// Equals on `ModelId` is not appropriate because injected items from different execution have same `executionId`.
4548
modelToValueMap
46-
.filter { it.key.contains(model) }
49+
.filter { models -> models.key.any { it === modelToFind } }
4750
.entries
4851
.singleOrNull()
4952
?.value

0 commit comments

Comments
 (0)