Skip to content

Commit 397a080

Browse files
committed
Lift out experimentality where it is applicable
* CoroutineDispatcher.invoke * ReceiveChannel.consume and ReceiveChannel.consumeEach * Flow core operators: onStart, onCompletion, onEmpty * CompletableDeferred.completeWith * awaitCancellation * Add experimentality notes where applicable
1 parent ea4ece3 commit 397a080

File tree

11 files changed

+8
-17
lines changed

11 files changed

+8
-17
lines changed

kotlinx-coroutines-core/common/src/Builders.common.kt

-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public suspend fun <T> withContext(
175175
*
176176
* This inline function calls [withContext].
177177
*/
178-
@ExperimentalCoroutinesApi
179178
public suspend inline operator fun <T> CoroutineDispatcher.invoke(
180179
noinline block: suspend CoroutineScope.() -> T
181180
): T = withContext(this, block)

kotlinx-coroutines-core/common/src/CompletableDeferred.kt

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public interface CompletableDeferred<T> : Deferred<T> {
5757
* This function transitions this deferred in the same ways described by [CompletableDeferred.complete] and
5858
* [CompletableDeferred.completeExceptionally].
5959
*/
60-
@ExperimentalCoroutinesApi // since 1.3.2, tentatively until 1.4.0
6160
public fun <T> CompletableDeferred<T>.completeWith(result: Result<T>): Boolean =
6261
result.fold({ complete(it) }, { completeExceptionally(it) })
6362

kotlinx-coroutines-core/common/src/CoroutineStart.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public enum class CoroutineStart {
5555
* Cancellability of coroutine at suspension points depends on the particular implementation details of
5656
* suspending functions as in [DEFAULT].
5757
*/
58-
@ExperimentalCoroutinesApi
58+
@ExperimentalCoroutinesApi // Since 1.0.0, no ETA on stability
5959
ATOMIC,
6060

6161
/**
@@ -71,7 +71,7 @@ public enum class CoroutineStart {
7171
*
7272
* **Note: This is an experimental api.** Execution semantics of coroutines may change in the future when this mode is used.
7373
*/
74-
@ExperimentalCoroutinesApi
74+
@ExperimentalCoroutinesApi // Since 1.0.0, no ETA on stability
7575
UNDISPATCHED;
7676

7777
/**

kotlinx-coroutines-core/common/src/Debug.common.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal expect fun assert(value: () -> Boolean)
2727
* Copy mechanism is used only on JVM, but it might be convenient to implement it in common exceptions,
2828
* so on JVM their stacktraces will be properly recovered.
2929
*/
30-
@ExperimentalCoroutinesApi
30+
@ExperimentalCoroutinesApi // Since 1.2.0, no ETA on stability
3131
public interface CopyableThrowable<T> where T : Throwable, T : CopyableThrowable<T> {
3232

3333
/**

kotlinx-coroutines-core/common/src/Delay.kt

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public interface Delay {
9595
* }
9696
* ```
9797
*/
98-
@ExperimentalCoroutinesApi
9998
public suspend fun awaitCancellation(): Nothing = suspendCancellableCoroutine {}
10099

101100
/**

kotlinx-coroutines-core/common/src/channels/Channels.common.kt

-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ public fun consumesAll(vararg channels: ReceiveChannel<*>): CompletionHandler =
150150
*
151151
* The operation is _terminal_.
152152
*/
153-
@ExperimentalCoroutinesApi // since 1.3.0, tentatively graduates in 1.4.0
154153
public inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -> R): R {
155154
var cause: Throwable? = null
156155
try {
@@ -171,7 +170,6 @@ public inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -
171170
* The operation is _terminal_.
172171
* This function [consumes][ReceiveChannel.consume] all elements of the original [ReceiveChannel].
173172
*/
174-
@ExperimentalCoroutinesApi // since 1.3.0, tentatively graduates in 1.4.x
175173
public suspend inline fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit): Unit =
176174
consume {
177175
for (e in this) action(e)

kotlinx-coroutines-core/common/src/flow/Builders.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ public fun LongRange.asFlow(): Flow<Long> = flow {
204204
@FlowPreview
205205
@Deprecated(
206206
message = "Use channelFlow with awaitClose { } instead of flowViaChannel and invokeOnClose { }.",
207-
level = DeprecationLevel.WARNING
208-
)
207+
level = DeprecationLevel.ERROR
208+
) // To be removed in 1.4.x
209209
@Suppress("DeprecatedCallableAddReplaceWith")
210210
public fun <T> flowViaChannel(
211211
bufferSize: Int = BUFFERED,

kotlinx-coroutines-core/common/src/flow/Migration.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ public fun <T, R> Flow<T>.switchMap(transform: suspend (value: T) -> Flow<R>): F
434434
message = "'scanReduce' was renamed to 'runningReduce' to be consistent with Kotlin standard library",
435435
replaceWith = ReplaceWith("runningReduce(operation)")
436436
)
437-
@ExperimentalCoroutinesApi
438437
public fun <T> Flow<T>.scanReduce(operation: suspend (accumulator: T, value: T) -> T): Flow<T> = runningReduce(operation)
439438

440439
@Deprecated(
@@ -482,4 +481,4 @@ public fun <T> Flow<T>.replay(bufferSize: Int): Flow<T> = noImpl()
482481
message = "Flow analogue of 'cache()' is 'shareIn' with unlimited replay and 'started = SharingStared.Lazily' argument'",
483482
replaceWith = ReplaceWith("this.shareIn(scope, Int.MAX_VALUE, started = SharingStared.Lazily)")
484483
)
485-
public fun <T> Flow<T>.cache(): Flow<T> = noImpl()
484+
public fun <T> Flow<T>.cache(): Flow<T> = noImpl()

kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt

-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ internal inline fun <T, R> Flow<T>.unsafeTransform(
7171
* .collect { println(it) } // prints Begin, a, b, c
7272
* ```
7373
*/
74-
@ExperimentalCoroutinesApi
7574
public fun <T> Flow<T>.onStart(
7675
action: suspend FlowCollector<T>.() -> Unit
7776
): Flow<T> = unsafeFlow { // Note: unsafe flow is used here, but safe collector is used to invoke start action
@@ -142,7 +141,6 @@ public fun <T> Flow<T>.onStart(
142141
* In case of failure or cancellation, any attempt to emit additional elements throws the corresponding exception.
143142
* Use [catch] if you need to suppress failure and replace it with emission of elements.
144143
*/
145-
@ExperimentalCoroutinesApi
146144
public fun <T> Flow<T>.onCompletion(
147145
action: suspend FlowCollector<T>.(cause: Throwable?) -> Unit
148146
): Flow<T> = unsafeFlow { // Note: unsafe flow is used here, but safe collector is used to invoke completion action
@@ -173,7 +171,6 @@ public fun <T> Flow<T>.onCompletion(
173171
* }.collect { println(it) } // prints 1, 2
174172
* ```
175173
*/
176-
@ExperimentalCoroutinesApi
177174
public fun <T> Flow<T>.onEmpty(
178175
action: suspend FlowCollector<T>.() -> Unit
179176
): Flow<T> = unsafeFlow {

reactive/kotlinx-coroutines-jdk9/src/Publish.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.reactivestreams.FlowAdapters
2828
* **Note: This is an experimental api.** Behaviour of publishers that work as children in a parent scope with respect
2929
* to cancellation and error handling may change in the future.
3030
*/
31-
@ExperimentalCoroutinesApi
31+
@ExperimentalCoroutinesApi // Since 1.3.x
3232
public fun <T> flowPublish(
3333
context: CoroutineContext = EmptyCoroutineContext,
3434
@BuilderInference block: suspend ProducerScope<T>.() -> Unit

ui/kotlinx-coroutines-javafx/src/JavaFxConvert.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import kotlinx.coroutines.flow.*
2424
* Adjacent applications of [flowOn], [buffer], [conflate], and [produceIn] to the result of `asFlow` are fused.
2525
* [conflate] has no effect, as this flow is already conflated; one can use [buffer] to change that instead.
2626
*/
27-
@ExperimentalCoroutinesApi
27+
@ExperimentalCoroutinesApi // Since 1.3.x
2828
public fun <T> ObservableValue<T>.asFlow(): Flow<T> = callbackFlow<T> {
2929
val listener = ChangeListener<T> { _, _, newValue ->
3030
try {

0 commit comments

Comments
 (0)