import kotlin.coroutines.Continuation
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.coroutines.intrinsics.createCoroutineUnintercepted

fun main() {
    // Define a suspend lambda that returns "Hello World!"
    val suspendingLambda: suspend () -> String = suspend {
        "Hello World!"
    }

    // Define a callback object
    val completionCallback = object : Continuation<String> {
        override val context: CoroutineContext = EmptyCoroutineContext
        override fun resumeWith(result: Result<String>) {
            // Prints "Hello World!"
            println(result.getOrNull())
        }
    }

    // Create the coroutine
    val continuation = suspendingLambda.createCoroutineUnintercepted(completionCallback)

    // Start the coroutine
    continuation.resumeWith(Result.success(Unit))
}