Does anyone understand why this is considered invalid? If I am instantiating this object within the scope of a suspended function, then this should be supported correct? Or are property getters not allowed to execute suspended code for some reason?
function body directly then capture the result in anonymous object.
e
Emanuel Moecklin
01/08/2023, 10:33 PM
instantiating an object in a suspend function doesn't automatically make its function or property getter calls suspend (why should it?), the real question is why
to()
has to be a suspend function? it's just creating an object, no suspend functions are being called so just make it a regular function
Emanuel Moecklin
01/08/2023, 10:37 PM
suspend property getters aren't supported by Kotlin
the coding conventions state that properties should be ācheap to calculateā and I would go even further and say, they should only contain trivial calculations.
Suspend does not really fit well with this idea of properties.