File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework/assemble Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -254,25 +254,27 @@ class AssembleModelGenerator(private val basePackageName: String) {
254
254
instantiatedModels[compositeModel] = this
255
255
256
256
compositeModel.fields.forEach { (fieldId, fieldModel) ->
257
+ // if field value has been filled by constructor or it is default, we suppose that it is already properly initialized
258
+ if ((fieldId in constructorInfo.setFields || fieldModel.hasDefaultValue()) && fieldId !in constructorInfo.affectedFields)
259
+ return @forEach
260
+
257
261
if (fieldId.isStatic) {
258
262
throw AssembleException (" Static field $fieldId can't be set in an object of the class $classId " )
259
263
}
260
- if (fieldId.isFinal) {
261
- throw AssembleException (" Final field $fieldId can't be set in an object of the class $classId " )
262
- }
264
+
263
265
if (! fieldId.type.isAccessibleFrom(basePackageName)) {
264
266
throw AssembleException (
265
267
" Field $fieldId can't be set in an object of the class $classId because its type is inaccessible"
266
268
)
267
269
}
268
- // fill field value if it hasn't been filled by constructor, and it is not default
269
- if (fieldId in constructorInfo.affectedFields ||
270
- (fieldId !in constructorInfo.setFields && ! fieldModel.hasDefaultValue())
271
- ) {
272
- val assembledModel = assembleModel(fieldModel)
273
- val modifierCall = modifierCall(this , fieldId, assembledModel)
274
- callChain.add(modifierCall)
270
+
271
+ if (fieldId.isFinal) {
272
+ throw AssembleException (" Final field $fieldId can't be set in an object of the class $classId " )
275
273
}
274
+
275
+ val assembledModel = assembleModel(fieldModel)
276
+ val modifierCall = modifierCall(this , fieldId, assembledModel)
277
+ callChain.add(modifierCall)
276
278
}
277
279
278
280
callChain.toList()
You can’t perform that action at this time.
0 commit comments