Skip to content

Commit 2c69326

Browse files
authored
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 83341fd commit 2c69326

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
@@ -1074,7 +1074,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
10741074
emptyLineIfNeeded()
10751075

10761076
actual = newVar(
1077-
CgClassId(executable.returnType, isNullable = result is UtNullModel),
1077+
CgClassId(result.classId, isNullable = result is UtNullModel),
10781078
"actual"
10791079
) {
10801080
thisInstance[executable](*methodArguments.toTypedArray())

0 commit comments

Comments
 (0)