PY-81941 Make CallInstruction.isNoReturnCall non-recursive

(cherry picked from commit 4c9c1e2c6a42b6632d84667a31fb4f46936405b3)

GitOrigin-RevId: aa5d89a12fbb6f0bdda6c78b53123f6fcae5785d
This commit is contained in:
Petr
2025-09-23 15:29:33 +02:00
committed by intellij-monorepo-bot
parent b274df9909
commit f18ba33412

View File

@@ -17,10 +17,14 @@ class CallInstruction(builder: ControlFlowBuilder, call: PyCallExpression) : Ins
val callees = element.multiResolveCalleeFunction(PyResolveContext.defaultContext(context))
if (callees.size == 1) {
val pyFunction = callees.single()
if (pyFunction is PyFunction) {
if (pyFunction is PyFunction && hasReturnTypeAnnotation(pyFunction)) {
return context.getReturnType(pyFunction) is PyNeverType
}
}
return false
}
}
private fun hasReturnTypeAnnotation(function: PyFunction): Boolean {
return function.annotation != null || function.typeCommentAnnotation != null
}