Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.utbot.tests.infrastructure.TestExecution
class AnonymousClassesExampleTest : UtValueTestCaseChecker(
testClass = AnonymousClassesExample::class,
pipelines = listOf(
TestLastStage(CodegenLanguage.JAVA, lastStage = TestExecution, parameterizedModeLastStage = Compilation),
TestLastStage(CodegenLanguage.KOTLIN, lastStage = TestExecution)
TestLastStage(CodegenLanguage.JAVA),
TestLastStage(CodegenLanguage.KOTLIN)
)
) {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ data class CgMethodTestSet constructor(
* A separate test set is created for each combination of modified statics.
*/
private fun splitExecutionsByChangedStatics(): List<CgMethodTestSet> {
val executionsByStaticsUsage: Map<Set<FieldId>, List<UtExecution>> =
executions.groupBy { it.stateBefore.statics.keys }
val executionsByStaticsUsage = executions.groupBy { it.stateBefore.statics.keys }

return executionsByStaticsUsage.map { (_, executions) -> substituteExecutions(executions) }
val executionsByStaticsUsageAndTheirTypes = executionsByStaticsUsage
.flatMap { (_, executions) ->
executions.groupBy { it.stateBefore.statics.values.map { model -> model.classId } }.values
}

return executionsByStaticsUsageAndTheirTypes.map { executions -> substituteExecutions(executions) }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import org.utbot.framework.plugin.api.util.fieldClassId
import org.utbot.framework.plugin.api.util.isPrimitive
import org.utbot.framework.plugin.api.util.methodClassId
import org.utbot.framework.plugin.api.util.denotableType
import org.utbot.framework.plugin.api.util.supertypeOfAnonymousClass
import java.lang.reflect.Constructor
import java.lang.reflect.Method
import kotlin.reflect.KFunction
Expand Down Expand Up @@ -484,7 +485,13 @@ internal class CgStatementConstructorImpl(context: CgContext) :
}

override fun wrapTypeIfRequired(baseType: ClassId): ClassId =
if (baseType.isAccessibleFrom(testClassPackageName)) baseType else objectClassId
when {
baseType.isAccessibleFrom(testClassPackageName) -> baseType
baseType.isAnonymous && baseType.supertypeOfAnonymousClass.isAccessibleFrom(testClassPackageName) ->
baseType.supertypeOfAnonymousClass

else -> objectClassId
}

// utils

Expand Down