File tree Expand file tree Collapse file tree 4 files changed +17
-15
lines changed
main/kotlin/org/utbot/engine
test/kotlin/org/utbot/examples/objects
utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api Expand file tree Collapse file tree 4 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -519,20 +519,13 @@ data class UtDirectSetFieldModel(
519
519
val fieldId : FieldId ,
520
520
val fieldModel : UtModel ,
521
521
) : UtStatementModel(instance) {
522
- private val fieldName
523
- get() =
524
- if (instance.classId == fieldId.declaringClass)
525
- " ${instance.modelName} .${fieldId.name} "
526
- else
527
- " ${instance.modelName} .(${fieldId.declaringClass.name} )${fieldId.name} "
528
-
529
522
530
523
override fun toString (): String = withToStringThreadLocalReentrancyGuard {
531
524
val modelRepresentation = when (fieldModel) {
532
525
is UtAssembleModel -> fieldModel.modelName
533
526
else -> fieldModel.toString()
534
527
}
535
- " $fieldName = $modelRepresentation "
528
+ " ${instance.modelName} . ${fieldId.name} = $modelRepresentation "
536
529
}
537
530
538
531
}
@@ -813,6 +806,9 @@ enum class FieldIdStrategyValues {
813
806
*/
814
807
open class FieldId (val declaringClass : ClassId , val name : String ) {
815
808
809
+ init {
810
+ // assert(declaringClass.jClass.declaredFields.any { it.name == name })
811
+ }
816
812
object Strategy {
817
813
var value: FieldIdStrategyValues = FieldIdStrategyValues .Soot
818
814
}
Original file line number Diff line number Diff line change @@ -288,7 +288,11 @@ val ClassId.isIterableOrMap: Boolean
288
288
fun ClassId.fieldOrNull (fieldId : FieldId ): Field ? {
289
289
if (this .isNotSubtypeOf(fieldId.declaringClass))
290
290
return null
291
- return fieldId.field
291
+ return try {
292
+ fieldId.field
293
+ } catch (e: Exception ) {
294
+ null
295
+ }
292
296
}
293
297
294
298
fun ClassId.hasField (fieldId : FieldId ): Boolean = fieldOrNull(fieldId) != null
Original file line number Diff line number Diff line change @@ -30,9 +30,14 @@ class Hierarchy(private val typeRegistry: TypeRegistry) {
30
30
val realType = typeRegistry.findRealType(type) as RefType
31
31
32
32
33
- val ancestorType = field.declaringClass
34
- // val ancestorType = ancestors(realType.sootClass.id).firstOrNull { it.declaresField(field.subSignature) }?.type
35
- // ?: error("No such field ${field.subSignature} found in ${realType.sootClass.name}")
33
+ /* val ancestorType = field.declaringClass
34
+ val ancestorType2 = ancestors(realType.sootClass.id).firstOrNull { it.declaresField(field.subSignature) }?.type
35
+ ?: error("No such field ${field.subSignature} found in ${realType.sootClass.name}")*/
36
+ val ancestorType = if (field.declaringClass in ancestors(realType.sootClass.id))
37
+ field.declaringClass
38
+ else
39
+ ancestors(realType.sootClass.id).firstOrNull { it.declaresField(field.subSignature) }?.type
40
+ ? : error(" No such field ${field.subSignature} found in ${realType.sootClass.name} " )
36
41
return ChunkId (" $ancestorType " , field.name)
37
42
}
38
43
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test
7
7
8
8
internal class HiddenFieldExampleTest : UtValueTestCaseChecker (testClass = HiddenFieldExample : :class) {
9
9
@Test
10
- // Engine creates HiddenFieldSuccClass instead of HiddenFieldSuperClass, feels wrong field and matchers fail
11
10
fun testCheckHiddenField () {
12
11
check(
13
12
HiddenFieldExample ::checkHiddenField,
@@ -21,8 +20,6 @@ internal class HiddenFieldExampleTest : UtValueTestCaseChecker(testClass = Hidde
21
20
}
22
21
23
22
@Test
24
- // @Disabled("SAT-315 Engine cannot work with hidden fields")
25
- // Engine translates calls to super.b as calls to succ.b
26
23
fun testCheckSuccField () {
27
24
check(
28
25
HiddenFieldExample ::checkSuccField,
You can’t perform that action at this time.
0 commit comments