@@ -1484,9 +1484,12 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1484
1484
substituteStaticFields(statics, isParametrized = true )
1485
1485
1486
1486
// build this instance
1487
- thisInstance =
1488
- genericExecution.stateBefore.thisInstance?.let {
1489
- variableConstructor.getOrCreateVariable(it)
1487
+ thisInstance = genericExecution.stateBefore.thisInstance?.let {
1488
+ if (statics.isNotEmpty()) {
1489
+ currentMethodParameters[CgParameterKind .ThisInstance ]
1490
+ } else {
1491
+ variableConstructor.getOrCreateVariable(it)
1492
+ }
1490
1493
}
1491
1494
1492
1495
// build arguments for method under test and parameterized test
@@ -1549,6 +1552,24 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1549
1552
val executableUnderTestParameters = testSet.executableId.executable.parameters
1550
1553
1551
1554
return mutableListOf<CgParameterDeclaration >().apply {
1555
+ val statics = genericExecution.stateBefore.statics
1556
+
1557
+ // this instance
1558
+ genericExecution.stateBefore.thisInstance?.let {
1559
+ if (statics.isNotEmpty()) {
1560
+ val type = wrapTypeIfRequired(it.classId)
1561
+ val thisInstance = CgParameterDeclaration (
1562
+ parameter = declareParameter(
1563
+ type = type,
1564
+ name = nameGenerator.variableName(type)
1565
+ ),
1566
+ isReferenceType = true
1567
+ )
1568
+ this + = thisInstance
1569
+ currentMethodParameters[CgParameterKind .ThisInstance ] = thisInstance.parameter
1570
+ }
1571
+ }
1572
+
1552
1573
// arguments
1553
1574
for (index in genericExecution.stateBefore.parameters.indices) {
1554
1575
val argumentName = paramNames[executableUnderTest]?.get(index)
@@ -1571,7 +1592,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1571
1592
currentMethodParameters[CgParameterKind .Argument (index)] = argument.parameter
1572
1593
}
1573
1594
1574
- val statics = genericExecution.stateBefore.statics
1575
1595
if (statics.isNotEmpty()) {
1576
1596
for ((fieldId, model) in statics) {
1577
1597
val staticType = wrapTypeIfRequired(model.classId)
@@ -1660,12 +1680,18 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1660
1680
private fun createExecutionArguments (testSet : CgMethodTestSet , execution : UtExecution ): List <CgExpression > {
1661
1681
val arguments = mutableListOf<CgExpression >()
1662
1682
1683
+ val statics = execution.stateBefore.statics
1684
+ execution.stateBefore.thisInstance?.let {
1685
+ if (statics.isNotEmpty()) {
1686
+ arguments + = variableConstructor.getOrCreateVariable(it)
1687
+ }
1688
+ }
1689
+
1663
1690
for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
1664
1691
val argumentName = paramNames[testSet.executableId]?.get(paramIndex)
1665
1692
arguments + = variableConstructor.getOrCreateVariable(paramModel, argumentName)
1666
1693
}
1667
1694
1668
- val statics = execution.stateBefore.statics
1669
1695
for ((field, model) in statics) {
1670
1696
arguments + = variableConstructor.getOrCreateVariable(model, field.name)
1671
1697
}
0 commit comments