File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,8 @@ class AssembleModelGenerator(private val basePackageName: String) {
226
226
assembleModel
227
227
}
228
228
229
+ private val modelsInAnalysis = mutableListOf<UtCompositeModel >()
230
+
229
231
/* *
230
232
* Assembles internal structure of [UtCompositeModel] if possible and handles assembling exceptions.
231
233
*/
@@ -243,7 +245,14 @@ class AssembleModelGenerator(private val basePackageName: String) {
243
245
val constructorId = findBestConstructorOrNull(compositeModel)
244
246
? : throw AssembleException (" No default constructor to instantiate an object of the class ${compositeModel.classId} " )
245
247
246
- val constructorInfo = constructorAnalyzer.analyze(constructorId)
248
+ // we do not analyze a constructor which is currently in the analysis
249
+ // thus, we do not encounter an infinite loop in self or cross-reference situations
250
+ val shouldAnalyzeConstructor = compositeModel !in modelsInAnalysis
251
+ modelsInAnalysis.add(compositeModel)
252
+
253
+ val constructorInfo =
254
+ if (shouldAnalyzeConstructor) constructorAnalyzer.analyze(constructorId)
255
+ else ConstructorAssembleInfo (constructorId)
247
256
248
257
val instantiationCall = constructorCall(compositeModel, constructorInfo)
249
258
return UtAssembleModel (
@@ -284,6 +293,8 @@ class AssembleModelGenerator(private val basePackageName: String) {
284
293
} catch (e: AssembleException ) {
285
294
instantiatedModels.remove(compositeModel)
286
295
throw e
296
+ } finally {
297
+ modelsInAnalysis.remove(compositeModel)
287
298
}
288
299
}
289
300
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ import soot.jimple.internal.JimpleLocal
33
33
* */
34
34
data class ConstructorAssembleInfo (
35
35
val constructorId : ConstructorId ,
36
- val params : Map <Int , FieldId >,
37
- val setFields : Set <FieldId >,
38
- val affectedFields : Set <FieldId >
36
+ val params : Map <Int , FieldId > = mapOf() ,
37
+ val setFields : Set <FieldId > = setOf() ,
38
+ val affectedFields : Set <FieldId > = setOf()
39
39
)
40
40
41
41
/* *
@@ -116,11 +116,6 @@ class ConstructorAnalyzer {
116
116
setFields : MutableSet <FieldId >,
117
117
affectedFields : MutableSet <FieldId >,
118
118
): Map <Int , FieldId > {
119
- if (sootConstructor in visitedConstructors) {
120
- return emptyMap()
121
- }
122
- visitedConstructors.add(sootConstructor)
123
-
124
119
val jimpleBody = retrieveJimpleBody(sootConstructor) ? : return emptyMap()
125
120
analyzeAssignments(jimpleBody, setFields, affectedFields)
126
121
You can’t perform that action at this time.
0 commit comments