https://kotlinlang.org logo
Title
g

gregd

11/30/2017, 11:30 PM
Hi all :kotlin: Has someone already noticed/reported that
suspend
doesn’t work with
typealias
? Example:
typealias MyType = (Any) -> Any
fun testFunction(block: suspend MyType) {}
//                      ^^^^^^^
// Modifier 'suspend' is not applicable to 'non-functional type'
d

dave08

12/01/2017, 3:42 AM
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

elizarov

12/01/2017, 7:50 AM
This is so by design.
d

dave08

12/01/2017, 8:13 AM
@elizarov You mean like he did it, but
typealias MyType = suspend (Any) -> Any
should work, no?
e

elizarov

12/01/2017, 8:38 AM
Yes.
suspend Alias
should not, while
suspend FunType
should work
👍🏼 1