Hi all :kotlin: Has someone already noticed/report...
# coroutines
g
Hi all K Has someone already noticed/reported that
suspend
doesn’t work with
typealias
? Example:
Copy code
typealias MyType = (Any) -> Any
fun testFunction(block: suspend MyType) {}
//                      ^^^^^^^
// Modifier 'suspend' is not applicable to 'non-functional type'
d
Did you try
typealias MyType = suspend (Any) -> Any
? I think it wouldn't make sense in the way you did it since
suspend
adds another parameter to the function when compiling, so it's another type altogether... but then maybe
typealias
might also be compile time, so it might be possible.... but a bit hacky?
e
This is so by design.
d
@elizarov You mean like he did it, but
typealias MyType = suspend (Any) -> Any
should work, no?
e
Yes.
suspend Alias
should not, while
suspend FunType
should work
👍🏼 1