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) {
241
241
val modelName = nextModelName(compositeModel.classId.jClass.simpleName.decapitalize())
242
242
243
243
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 } " )
245
245
246
246
val constructorInfo = constructorAnalyzer.analyze(constructorId)
247
247
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.utbot.framework.plugin.api.id
7
7
import org.utbot.framework.plugin.api.util.isArray
8
8
import org.utbot.framework.plugin.api.util.isRefType
9
9
import org.utbot.framework.plugin.api.util.jClass
10
+ import org.utbot.framework.util.kotlinIntrinsicsClassId
10
11
import soot.Scene
11
12
import soot.SootMethod
12
13
import soot.Type
@@ -173,8 +174,8 @@ class ConstructorAnalyzer {
173
174
val jimpleLocal = assn.rightOp as ? JimpleLocal ? : continue
174
175
175
176
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)
178
179
}
179
180
180
181
return indexedFields
@@ -226,6 +227,8 @@ class ConstructorAnalyzer {
226
227
jimpleBody.units
227
228
.filterIsInstance<JInvokeStmt >()
228
229
.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 }
229
232
230
233
private fun sameParameterTypes (sootMethod : SootMethod , constructorId : ConstructorId ): Boolean {
231
234
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