alexandrepiveteau
01/29/2021, 1:36 PM@DslMarker
annotation on a suspend
scope receiver ?
I’m getting an java.lang.IllegalStateException: Backend Internal error: Exception during IR lowering
exception when I write the following code, but don’t face any issue when I remove the suspend
modifier :
@DslMarker
annotation class MyDslMarker
@MyDslMarker
interface MyDsl
fun something(
scope: suspend MyDsl.() -> Unit,
) {
}
fun main() {
something { }
}
Youssef Shoaib [MOD]
01/29/2021, 1:54 PMfun something
inline so that the user can call suspend funs if they're in a suspend scope. Also, try removing the @MyDslMarker while keeping the suspend modifier and check what happens because the issue could be elsewhereYoussef Shoaib [MOD]
01/29/2021, 1:59 PMimport kotlinx.coroutines.*
@DslMarker
annotation class MyDslMarker
@MyDslMarker
interface MyDsl
fun something(
scope: suspend MyDsl.() -> Unit
) {
runBlocking {
scope(object : MyDsl {})
}
}
fun main() {
something { println("test") }
}
alexandrepiveteau
01/29/2021, 2:06 PM@MyDslMarker
annotation from MyDsl
, the snippet compiles and runs without issues.
It’s interesting that the code compiles properly on the Kotlin playground; I’m wondering if the issue might come from the fact that I’m using Jetpack Compose (and maybe the new IR backend).Youssef Shoaib [MOD]
01/29/2021, 2:08 PMfun interface
with a suspend function instead)udalov
alexandrepiveteau
01/29/2021, 7:14 PMudalov