File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ class AssembleModelGenerator(private val basePackageName: String) {
241241 val modelName = nextModelName(compositeModel.classId.jClass.simpleName.decapitalize())
242242
243243 val constructorId = findBestConstructorOrNull(compositeModel)
244- ? : throw AssembleException (" No default constructor to instantiate an object of the class ${compositeModel.id } " )
244+ ? : throw AssembleException (" No default constructor to instantiate an object of the class ${compositeModel.classId } " )
245245
246246 val constructorInfo = constructorAnalyzer.analyze(constructorId)
247247
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.utbot.framework.plugin.api.id
77import org.utbot.framework.plugin.api.util.isArray
88import org.utbot.framework.plugin.api.util.isRefType
99import org.utbot.framework.plugin.api.util.jClass
10+ import org.utbot.framework.util.kotlinIntrinsicsClassId
1011import soot.Scene
1112import soot.SootMethod
1213import soot.Type
@@ -173,8 +174,8 @@ class ConstructorAnalyzer {
173174 val jimpleLocal = assn.rightOp as ? JimpleLocal ? : continue
174175
175176 val field = (assn.leftOp as ? JInstanceFieldRef )?.field ? : continue
176- val parameterIndex = jimpleBody.locals .indexOfFirst { it.name == jimpleLocal.name }
177- indexedFields[parameterIndex - 1 ] = FieldId (field.declaringClass.id, field.name)
177+ val parameterIndex = jimpleBody.parameterLocals .indexOfFirst { it.name == jimpleLocal.name }
178+ indexedFields[parameterIndex] = FieldId (field.declaringClass.id, field.name)
178179 }
179180
180181 return indexedFields
@@ -226,6 +227,8 @@ class ConstructorAnalyzer {
226227 jimpleBody.units
227228 .filterIsInstance<JInvokeStmt >()
228229 .map { it.invokeExpr }
230+ // These are instructions inserted by Kotlin compiler to check that arguments are not null, we should ignore them
231+ .filterNot { it.method.declaringClass.id == kotlinIntrinsicsClassId }
229232
230233 private fun sameParameterTypes (sootMethod : SootMethod , constructorId : ConstructorId ): Boolean {
231234 val sootConstructorTypes = sootMethod.parameterTypes
Original file line number Diff line number Diff line change 1+ package org.utbot.framework.util
2+
3+ import org.utbot.framework.plugin.api.BuiltinClassId
4+
5+ val kotlinIntrinsicsClassId: BuiltinClassId
6+ get() = BuiltinClassId (
7+ simpleName = " Intrinsics" ,
8+ canonicalName = " kotlin.jvm.internal.Intrinsics" ,
9+ packageName = " kotlin.jvm.internal"
10+ )
You can’t perform that action at this time.
0 commit comments