You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a bug in the kotlin2js compiler. When a suspend function is part of a delegate, the suspend function is called without continuation object. Here is a simple example: (tested with version 1.2.41)
interface SuspendInterface {
suspend fun hello()
}
object SuspendObject : SuspendInterface {
override suspend fun hello() {
delay(1000)
println("Hello from Kotlin Coroutines!")
}
}
class SuspendDelegate(suspendInterface: SuspendInterface) :
SuspendInterface by suspendInterface
fun main(args: Array<String>) {
println("Hello World!")
launch {
SuspendObject.hello()
SuspendDelegate(SuspendObject).hello()
}
}
The first call to hello() works as expected. The second one throws an exception:
TypeError: Cannot read property 'context' of undefined
at Coroutine$hello.CoroutineImpl (kotlin.js:30956)
at new Coroutine$hello (suspend.js:35)
at SuspendObject.hello (suspend.js:28)
at SuspendDelegate.hello (suspend.js:91)
at Coroutine$main$lambda.doResume (suspend.js:131)
at Coroutine$main$lambda.CoroutineImpl.doResumeWrapper_0 (kotlin.js:30976)
at Coroutine$main$lambda.CoroutineImpl.resume_11rb$ (kotlin.js:30965)
at Coroutine$hello.CoroutineImpl.doResumeWrapper_0 (kotlin.js:30978)
at Coroutine$hello.CoroutineImpl.resume_11rb$ (kotlin.js:30965)
at resumeMode (kotlinx-coroutines-core.js:602)
The text was updated successfully, but these errors were encountered:
There seems to be a bug in the kotlin2js compiler. When a suspend function is part of a delegate, the suspend function is called without continuation object. Here is a simple example: (tested with version 1.2.41)
The first call to hello() works as expected. The second one throws an exception:
The text was updated successfully, but these errors were encountered: