1
1
@file:JvmMultifileClass
2
2
@file:JvmName(" BuildersKt" )
3
3
@file:OptIn(ExperimentalContracts ::class )
4
+ @file:Suppress(" LEAKED_IN_PLACE_LAMBDA" , " WRONG_INVOCATION_KIND" )
4
5
5
6
package kotlinx.coroutines
6
7
@@ -153,7 +154,6 @@ public suspend fun <T> withContext(
153
154
// FAST PATH #1 -- new context is the same as the old one
154
155
if (newContext == = oldContext) {
155
156
val coroutine = ScopeCoroutine (newContext, uCont)
156
- @Suppress(" LEAKED_IN_PLACE_LAMBDA" ) // Contract is preserved, invoked immediately or throws
157
157
return @sc coroutine.startUndispatchedOrReturn(coroutine, block)
158
158
}
159
159
// FAST PATH #2 -- the new dispatcher is the same as the old one (something else changed)
@@ -162,13 +162,11 @@ public suspend fun <T> withContext(
162
162
val coroutine = UndispatchedCoroutine (newContext, uCont)
163
163
// There are changes in the context, so this thread needs to be updated
164
164
withCoroutineContext(coroutine.context, null ) {
165
- @Suppress(" LEAKED_IN_PLACE_LAMBDA" ) // Contract is preserved, invoked immediately or throws
166
165
return @sc coroutine.startUndispatchedOrReturn(coroutine, block)
167
166
}
168
167
}
169
168
// SLOW PATH -- use new dispatcher
170
169
val coroutine = DispatchedCoroutine (newContext, uCont)
171
- @Suppress(" LEAKED_IN_PLACE_LAMBDA" ) // Contract is preserved, invoked immediately or throws
172
170
block.startCoroutineCancellable(coroutine, coroutine)
173
171
coroutine.getResult()
174
172
}
0 commit comments