Skip to content

Commit cba891c

Browse files
committed
Backwards compatibility test
1 parent b9b8dc4 commit cba891c

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

kotlinx-coroutines-core/common/src/selects/Select.kt

+10-9
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ import kotlin.native.concurrent.*
5050
* Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed.
5151
*/
5252
public suspend inline fun <R> select(crossinline builder: SelectBuilder<R>.() -> Unit): R {
53-
contract {
54-
callsInPlace(builder, InvocationKind.EXACTLY_ONCE)
55-
}
56-
return SelectImplementation<R>(coroutineContext).run {
57-
builder(this)
58-
// TAIL-CALL OPTIMIZATION: the only
59-
// suspend call is at the last position.
60-
doSelect()
61-
}
53+
return selectOld(builder)
54+
// contract {
55+
// callsInPlace(builder, InvocationKind.EXACTLY_ONCE)
56+
// }
57+
// return SelectImplementation<R>(coroutineContext).run {
58+
// builder(this)
59+
// // TAIL-CALL OPTIMIZATION: the only
60+
// // suspend call is at the last position.
61+
// doSelect()
62+
// }
6263
}
6364

6465
/**

kotlinx-coroutines-core/common/src/selects/SelectOld.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal class UnbiasedSelectBuilderImpl<R>(
7373
}
7474

7575
// This is the old version of `select`. It should work to guarantee binary compatibility.
76-
internal suspend inline fun <R> selectOld(crossinline builder: SelectBuilder<R>.() -> Unit): R {
76+
public suspend inline fun <R> selectOld(crossinline builder: SelectBuilder<R>.() -> Unit): R {
7777
return suspendCoroutineUninterceptedOrReturn { uCont ->
7878
val scope = SelectBuilderImpl(uCont)
7979
try {
@@ -86,7 +86,7 @@ internal suspend inline fun <R> selectOld(crossinline builder: SelectBuilder<R>.
8686
}
8787

8888
// This is the old version of `selectUnbiased`. It should work to guarantee binary compatibility.
89-
internal suspend inline fun <R> selectUnbiasedOld(crossinline builder: SelectBuilder<R>.() -> Unit): R =
89+
public suspend inline fun <R> selectUnbiasedOld(crossinline builder: SelectBuilder<R>.() -> Unit): R =
9090
suspendCoroutineUninterceptedOrReturn { uCont ->
9191
val scope = UnbiasedSelectBuilderImpl(uCont)
9292
try {

kotlinx-coroutines-core/common/src/selects/SelectUnbiased.kt

+8-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ import kotlin.coroutines.*
1919
* See [select] function description for all the other details.
2020
*/
2121
public suspend inline fun <R> selectUnbiased(crossinline builder: SelectBuilder<R>.() -> Unit): R {
22-
contract {
23-
callsInPlace(builder, InvocationKind.EXACTLY_ONCE)
24-
}
25-
return UnbiasedSelectImplementation<R>(coroutineContext).run {
26-
builder(this)
27-
doSelect()
28-
}
22+
return selectUnbiasedOld(builder)
23+
// contract {
24+
// callsInPlace(builder, InvocationKind.EXACTLY_ONCE)
25+
// }
26+
// return UnbiasedSelectImplementation<R>(coroutineContext).run {
27+
// builder(this)
28+
// doSelect()
29+
// }
2930
}
3031

3132
/**

0 commit comments

Comments
 (0)