I want to launch sub-job inside of launch{}. This was child of parent job when coroutineContext was used as parameter. It’s deprecated, and I see only option to pass kotlin.coroutines.experimental.coroutineContext as parameter, which is long and ugly. Is there some other way, or how is this meant to work now?
I don’t import any, it uses those from kotlinx.coroutines.experimental.CoroutineScope.coroutineContext, and CoroutineScope is receiver parameter in coroutine block run by launch.
So these 2 have same name, and it automatically picks CoroutineScope.coroutineContext.
Are you by any chance using kotlin 1.3-M1? Because they are moving coroutiens out of the experimental package. There are some steps that need to be done for migration and calling code still compiled with the old experimental coroutines.
I can’t really tell you more because I did not yet try out the preview build of 1.3 myself. More info is here though:
Hi,
You have to import kotlin.coroutines.experimental.* or kotlin.coroutines.experimental.coroutineContext. CoroutineScope.coroutineContext is now marked as LowPriorityInOverloadResolution and deprecated with replacement, so IDEA can even quickfix that for you: 2018-08-15_1112