11package org.utbot.contest.usvm
22
33import org.jacodb.analysis.library.analyzers.thisInstance
4+ import org.jacodb.api.JcArrayType
45import org.jacodb.api.JcClassOrInterface
56import org.jacodb.api.JcClasspath
67import org.jacodb.api.JcField
78import org.jacodb.api.JcMethod
89import org.jacodb.api.JcPrimitiveType
10+ import org.jacodb.api.JcRefType
911import org.jacodb.api.JcType
1012import org.jacodb.api.TypeName
1113import org.jacodb.api.ext.boolean
1214import org.jacodb.api.ext.byte
1315import org.jacodb.api.ext.char
1416import org.jacodb.api.ext.double
15- import org.jacodb.api.ext.findClassOrNull
1617import org.jacodb.api.ext.float
1718import org.jacodb.api.ext.int
1819import org.jacodb.api.ext.long
1920import org.jacodb.api.ext.short
2021import org.jacodb.api.ext.void
22+ import org.jacodb.api.ext.toType
2123import org.usvm.instrumentation.testcase.api.UTestInst
2224import org.usvm.instrumentation.testcase.descriptor.UTestObjectDescriptor
2325import org.usvm.instrumentation.testcase.descriptor.UTestValueDescriptor
@@ -37,7 +39,6 @@ import org.utbot.framework.plugin.api.util.floatClassId
3739import org.utbot.framework.plugin.api.util.id
3840import org.utbot.framework.plugin.api.util.intClassId
3941import org.utbot.framework.plugin.api.util.longClassId
40- import org.utbot.framework.plugin.api.util.objectClassId
4142import org.utbot.framework.plugin.api.util.shortClassId
4243import org.utbot.framework.plugin.api.util.utContext
4344import org.utbot.framework.plugin.api.util.voidClassId
@@ -55,10 +56,18 @@ fun JcMethod.toExecutableId(classpath: JcClasspath): ExecutableId {
5556 return MethodId (type, this .name, returnClassId, parameters)
5657}
5758
59+ private fun JcType.replaceToBoundIfGeneric (): JcType {
60+ return when (this ) {
61+ is JcArrayType -> this .classpath.arrayTypeOf(elementType.replaceToBoundIfGeneric())
62+ is JcRefType -> this .jcClass.toType()
63+ else -> this
64+ }
65+ }
66+
5867val JcType ?.classId: ClassId
5968 get() {
6069 if (this !is JcPrimitiveType ) {
61- return this ?.toJavaClass(utContext.classLoader)?.id
70+ return this ?.replaceToBoundIfGeneric()?. toJavaClass(utContext.classLoader)?.id
6271 ? : error(" Can not construct classId for $this " )
6372 }
6473
0 commit comments