File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework/assemble Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -254,9 +254,6 @@ class AssembleModelGenerator(private val basePackageName: String) {
254
254
if (fieldId.isStatic) {
255
255
throw AssembleException (" Static field $fieldId can't be set in an object of the class $classId " )
256
256
}
257
- if (fieldId.isFinal) {
258
- throw AssembleException (" Final field $fieldId can't be set in an object of the class $classId " )
259
- }
260
257
if (! fieldId.type.isAccessibleFrom(basePackageName)) {
261
258
throw AssembleException (
262
259
" Field $fieldId can't be set in an object of the class $classId because its type is inaccessible"
@@ -266,6 +263,10 @@ class AssembleModelGenerator(private val basePackageName: String) {
266
263
if (fieldId in constructorInfo.affectedFields ||
267
264
(fieldId !in constructorInfo.setFields && ! fieldModel.hasDefaultValue())
268
265
) {
266
+ // Kotlin can set final fields in constructor, so we should only check for final fields not affected by constructor
267
+ if (fieldId.isFinal) {
268
+ throw AssembleException (" Final field $fieldId can't be set in an object of the class $classId " )
269
+ }
269
270
val assembledModel = assembleModel(fieldModel)
270
271
val modifierCall = modifierCall(this , fieldId, assembledModel)
271
272
callChain.add(modifierCall)
You can’t perform that action at this time.
0 commit comments