Skip to content

Commit 374a351

Browse files
authored
Add interfaces of superclasses in ancestors set (#1528)
1 parent 82a38d3 commit 374a351

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.utbot.examples.mixed
2+
3+
import org.junit.jupiter.api.Test
4+
import org.utbot.framework.plugin.api.CodegenLanguage
5+
import org.utbot.testcheckers.eq
6+
import org.utbot.testing.DoNotCalculate
7+
import org.utbot.testing.UtValueTestCaseChecker
8+
9+
internal class SerializableExampleTest : UtValueTestCaseChecker(testClass = SerializableExample::class) {
10+
11+
@Test
12+
fun testExample() {
13+
check(
14+
SerializableExample::example,
15+
eq(1),
16+
)
17+
}
18+
}

utbot-framework/src/main/kotlin/org/utbot/engine/Hierarchy.kt

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utbot.engine
22

3+
import org.utbot.engine.types.OBJECT_TYPE
34
import org.utbot.engine.types.TypeRegistry
45
import org.utbot.framework.plugin.api.ClassId
56
import org.utbot.framework.plugin.api.id
@@ -54,14 +55,20 @@ class Hierarchy(private val typeRegistry: TypeRegistry) {
5455

5556
private fun findAncestors(id: ClassId) =
5657
with(Scene.v().getSootClass(id.name)) {
57-
if (this.isInterface) {
58-
Scene.v().activeHierarchy.getSuperinterfacesOfIncluding(this)
58+
val superClasses = mutableListOf<SootClass>()
59+
val superInterfaces = mutableListOf<SootClass>()
60+
61+
if (isInterface) {
62+
superClasses += OBJECT_TYPE.sootClass
63+
superInterfaces += Scene.v().activeHierarchy.getSuperinterfacesOfIncluding(this)
5964
} else {
60-
Scene.v().activeHierarchy.getSuperclassesOfIncluding(this) +
61-
this.interfaces.flatMap {
62-
Scene.v().activeHierarchy.getSuperinterfacesOfIncluding(it)
63-
}
65+
superClasses += Scene.v().activeHierarchy.getSuperclassesOfIncluding(this)
66+
superInterfaces += superClasses
67+
.flatMap { it.interfaces }
68+
.flatMap { Scene.v().activeHierarchy.getSuperinterfacesOfIncluding(it) }
6469
}
70+
71+
superClasses + superInterfaces
6572
}
6673

6774
private fun findInheritors(id: ClassId) =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.utbot.examples.mixed;
2+
3+
import java.io.File;
4+
5+
public class SerializableExample {
6+
public void example() {
7+
join("string", File.separator, System.currentTimeMillis());
8+
}
9+
10+
public static <T> String join(T... elements) {
11+
return null;
12+
}
13+
}

0 commit comments

Comments
 (0)