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) {
254254 instantiatedModels[compositeModel] = this
255255
256256 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+
257261 if (fieldId.isStatic) {
258262 throw AssembleException (" Static field $fieldId can't be set in an object of the class $classId " )
259263 }
260- if (fieldId.isFinal) {
261- throw AssembleException (" Final field $fieldId can't be set in an object of the class $classId " )
262- }
264+
263265 if (! fieldId.type.isAccessibleFrom(basePackageName)) {
264266 throw AssembleException (
265267 " Field $fieldId can't be set in an object of the class $classId because its type is inaccessible"
266268 )
267269 }
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 " )
275273 }
274+
275+ val assembledModel = assembleModel(fieldModel)
276+ val modifierCall = modifierCall(this , fieldId, assembledModel)
277+ callChain.add(modifierCall)
276278 }
277279
278280 callChain.toList()
You can’t perform that action at this time.
0 commit comments