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) {
254254 if (fieldId.isStatic) {
255255 throw AssembleException (" Static field $fieldId can't be set in an object of the class $classId " )
256256 }
257- if (fieldId.isFinal) {
258- throw AssembleException (" Final field $fieldId can't be set in an object of the class $classId " )
259- }
260257 if (! fieldId.type.isAccessibleFrom(basePackageName)) {
261258 throw AssembleException (
262259 " 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) {
266263 if (fieldId in constructorInfo.affectedFields ||
267264 (fieldId !in constructorInfo.setFields && ! fieldModel.hasDefaultValue())
268265 ) {
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+ }
269270 val assembledModel = assembleModel(fieldModel)
270271 val modifierCall = modifierCall(this , fieldId, assembledModel)
271272 callChain.add(modifierCall)
You can’t perform that action at this time.
0 commit comments