Skip to content

Commit e34bf8b

Browse files
authored
Fix unnecessary indexed field names (e.g. entityManager4) #2560 (#2567)
1 parent 48264f3 commit e34bf8b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ abstract class CgAbstractClassFieldManager(context: CgContext) :
4545

4646
val baseVarName = constructBaseVarName(model)
4747

48-
val createdVariable = variableConstructor.getOrCreateVariable(model, baseVarName) as? CgVariable
49-
?: error("`CgVariable` cannot be constructed from a $model model")
48+
// `withNameScope` is used to avoid saving names for sub-models of model
49+
val createdVariable = withNameScope {
50+
variableConstructor.getOrCreateVariable(model, baseVarName) as? CgVariable
51+
?: error("`CgVariable` cannot be constructed from a $model model")
52+
}
53+
existingVariableNames.add(createdVariable.name)
5054

5155
val declaration = CgDeclaration(classId, variableName = createdVariable.name, initializer = null)
5256

0 commit comments

Comments
 (0)