So… what are the rules for when a (non-suspending)...
# announcements
So… what are the rules for when a (non-suspending) inline function can be used to call suspending code? .let(), for instance, works in both blocking and asynchronous contexts (ie, the lambda passed to .let() can call suspend functions if .let() was called from a coroutine body). However, it seems like if any restrictions are put on the lambda’s return type at all, suddenly it becomes necessary to declare your function as a
suspend inline
function (ie,
inline fun <T> foo(() -> T) {}
works in a suspend context;
inline fun foo(() -> Int) {}
does not). Am I correct about that? And if so, out of curiosity, what’s the implementation reason?
can you give an example?
inline fun foo(f: () -> Int)
should work just fine in suspending context
Hrrm….. I spoke too soon and I’m wrong about what’s happening. I think this may have been a case of intellij being confused by a file that has other unresolved errors in it. Apologies for the noise --- I’ll show myself out
I’ll update this thread either way once the issue is resolved
Confirmed --- intellij was just confused.