segunfamisa
07/31/2025, 4:41 PMfun foo() {
GlobalScope.launch {
// anonymous suspend function <===
try {
delay(1_000)
} catch (_: Exception) {
// general error handling
}
}
}
I need to be able to tell if the try-block is running within a suspend function (as is this case).
I have this so far:
// visitTryExpression
val function = expression.getParentOfType<KtFunction>(strict = true) ?: return
analyze(function) {
val symbol: KaAnonymousFunctionSymbol = function.symbol
// symbol.isSuspend does not exist
}
I noticed that KaAnonymousFunctionSymbol.isSuspend
does not exist, even though KaNamedFunctionSymbol.isSuspend
exists.
My question is: how does one get whether an anonymous function/lambda is a suspend function in the analysis API?eRoman Golyshev
08/01/2025, 8:53 AMRoman Golyshev
08/01/2025, 9:03 AMRoman Golyshev
08/01/2025, 9:03 AMsegunfamisa
08/01/2025, 9:59 AM