Skip to content

Commit 9737f4e

Browse files
ArsenHDdenis-fokin
authored andcommitted
Change type of 'actual' variable (#631)
Before the type of this variable was the same as the return type of executable under test. However, this could lead to undesired reflection usage: if a method returns 'A', but the real type of 'actual' variable is 'B' (subclass of A), then we will not be able to access fields that are declared in 'B' without reflection, because the variable is declared with type 'A'. For example, this can happen when we make assertions on field modifications and some of these fields are from 'B', but are not accessible, because type 'A' knows nothing about these new fields.
1 parent 8e91006 commit 9737f4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
10781078
emptyLineIfNeeded()
10791079

10801080
actual = newVar(
1081-
CgClassId(executable.returnType, isNullable = result is UtNullModel),
1081+
CgClassId(result.classId, isNullable = result is UtNullModel),
10821082
"actual"
10831083
) {
10841084
thisInstance[executable](*methodArguments.toTypedArray())

0 commit comments

Comments
 (0)