Skip to content

Commit 4374a26

Browse files
committed
Fix isRecursiveObject
1 parent 68cebed commit 4374a26

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • utbot-python/src/main/kotlin/org/utbot/python/framework/api/python

utbot-python/src/main/kotlin/org/utbot/python/framework/api/python/PythonTree.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ object PythonTree {
2828
return isRecursiveObjectDFS(tree, mutableSetOf())
2929
}
3030

31-
private fun isRecursiveObjectDFS(tree: PythonTreeNode, visited: MutableSet<PythonTreeNode>): Boolean {
31+
private fun isRecursiveObjectDFS(tree: PythonTreeNode, visited: Set<PythonTreeNode>): Boolean {
3232
if (tree is PrimitiveNode) {
3333
return false
3434
}
3535
if (visited.contains(tree))
3636
return true
37-
visited.add(tree)
38-
return tree.children.any { isRecursiveObjectDFS(it, visited) }
37+
return tree.children.any { isRecursiveObjectDFS(it, visited + tree) }
3938
}
4039

4140
fun containsFakeNode(tree: PythonTreeNode): Boolean {

0 commit comments

Comments
 (0)