Skip to content

Commit 7ed6b08

Browse files
authored
Make USVM descriptor to UtModel cache consider state kind (initial or final) (#2697)
1 parent 26751a5 commit 7ed6b08

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

utbot-junit-contest/src/main/kotlin/org/utbot/contest/usvm/converter/JcToUtModelConverter.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ class JcToUtModelConverter(
3838
private val jcClasspath: JcClasspath,
3939
private val instToUtModelConverter: UTestInstToUtModelConverter,
4040
) {
41-
private val descriptorToModelCache = mutableMapOf<UTestValueDescriptor, UtModel>()
41+
private val descriptorToModelCache =
42+
mutableMapOf<Pair<UTestValueDescriptor, EnvironmentStateKind>, UtModel>()
4243
private val refIdAndStateKindToDescriptorCache =
4344
mutableMapOf<Pair<Int, EnvironmentStateKind>, UTestValueDescriptor>()
4445

4546
fun convert(
4647
valueDescriptor: UTestValueDescriptor,
4748
stateKind: EnvironmentStateKind,
48-
): UtModel = descriptorToModelCache.getOrPut(valueDescriptor) {
49+
): UtModel = descriptorToModelCache.getOrPut(valueDescriptor to stateKind) {
4950
if (stateKind == EnvironmentStateKind.INITIAL || valueDescriptor.origin is UTestMock)
5051
valueDescriptor.origin?.let { originExpr ->
5152
val model = instToUtModelConverter.findModelByInst(originExpr as UTestExpression)
@@ -79,7 +80,7 @@ class JcToUtModelConverter(
7980
valueDescriptor: UTestValueDescriptor,
8081
stateKind: EnvironmentStateKind,
8182
curModelId: Int,
82-
): UtModel = descriptorToModelCache.getOrPut(valueDescriptor) {
83+
): UtModel = descriptorToModelCache.getOrPut(valueDescriptor to stateKind) {
8384
if (valueDescriptor is UTestRefDescriptor) {
8485
refIdAndStateKindToDescriptorCache[valueDescriptor.refId to stateKind] = valueDescriptor
8586
}
@@ -96,7 +97,7 @@ class JcToUtModelConverter(
9697
fields = fields,
9798
)
9899

99-
descriptorToModelCache[valueDescriptor] = model
100+
descriptorToModelCache[valueDescriptor to stateKind] = model
100101

101102
fields += valueDescriptor.fields
102103
.entries
@@ -120,7 +121,7 @@ class JcToUtModelConverter(
120121
stores = stores,
121122
)
122123

123-
descriptorToModelCache[valueDescriptor] = model
124+
descriptorToModelCache[valueDescriptor to stateKind] = model
124125

125126
valueDescriptor.value
126127
.map { elemDescr -> convert(elemDescr, stateKind) }
@@ -182,6 +183,6 @@ class JcToUtModelConverter(
182183
stateKind: EnvironmentStateKind
183184
): UtModel? =
184185
refIdAndStateKindToDescriptorCache[refId to stateKind]?.let {
185-
descriptorToModelCache[it]
186+
descriptorToModelCache[it to stateKind]
186187
}
187188
}

0 commit comments

Comments
 (0)