1 @file:Suppress("PackageDirectoryMismatch") 2 package example 3 4 import kotlinx.coroutines.* 5 <lambda>null6object PublicApiImplementation : CoroutineScope by CoroutineScope(CoroutineName("Example")) { 7 8 private fun doWork(): Int { 9 error("Internal invariant failed") 10 } 11 12 private fun asynchronousWork(): Int { 13 return doWork() + 1 14 } 15 16 public suspend fun awaitAsynchronousWorkInMainThread() { 17 val task = async(Dispatchers.Default) { 18 asynchronousWork() 19 } 20 21 task.await() 22 } 23 } 24 mainnull25suspend fun main() { 26 // Try to switch debug mode on and off to see the difference 27 PublicApiImplementation.awaitAsynchronousWorkInMainThread() 28 } 29