From ff9359a9370c26a81405e1eb895ee1c4686ffc91 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Thu, 25 Nov 2021 16:48:06 +0300 Subject: [PATCH] Get rid of @ExperimentalTime where it is no longer necessary (#3041) * Get rid of @ExperimentalTime where it is no longer necessary Fixes #3039 --- kotlinx-coroutines-core/common/src/Delay.kt | 2 - kotlinx-coroutines-core/common/src/Timeout.kt | 2 - .../common/src/flow/SharingStarted.kt | 1 - .../common/src/flow/operators/Delay.kt | 4 -- .../common/src/selects/Select.kt | 1 - .../common/test/DelayDurationTest.kt | 1 - .../common/test/WithTimeoutDurationTest.kt | 31 ++++++------- .../test/WithTimeoutOrNullDurationTest.kt | 43 ++++++++++--------- .../test/flow/operators/DebounceTest.kt | 28 ++++++------ .../common/test/flow/operators/SampleTest.kt | 14 +++--- .../SharingStartedWhileSubscribedTest.kt | 3 +- .../test/selects/SelectTimeoutDurationTest.kt | 19 ++++---- .../examples/example-delay-duration-01.kt | 1 - .../examples/example-delay-duration-02.kt | 1 - .../examples/example-delay-duration-03.kt | 1 - .../jvm/test/flow/SharedFlowStressTest.kt | 5 +-- .../common/test/Helpers.kt | 1 - 17 files changed, 70 insertions(+), 88 deletions(-) diff --git a/kotlinx-coroutines-core/common/src/Delay.kt b/kotlinx-coroutines-core/common/src/Delay.kt index d95dc52f9f..301ed2d322 100644 --- a/kotlinx-coroutines-core/common/src/Delay.kt +++ b/kotlinx-coroutines-core/common/src/Delay.kt @@ -133,7 +133,6 @@ public suspend fun delay(timeMillis: Long) { * * Implementation note: how exactly time is tracked is an implementation detail of [CoroutineDispatcher] in the context. */ -@ExperimentalTime public suspend fun delay(duration: Duration): Unit = delay(duration.toDelayMillis()) /** Returns [Delay] implementation of the given context */ @@ -143,6 +142,5 @@ internal val CoroutineContext.delay: Delay get() = get(ContinuationInterceptor) * Convert this duration to its millisecond value. * Positive durations are coerced at least `1`. */ -@ExperimentalTime internal fun Duration.toDelayMillis(): Long = if (this > Duration.ZERO) inWholeMilliseconds.coerceAtLeast(1) else 0 diff --git a/kotlinx-coroutines-core/common/src/Timeout.kt b/kotlinx-coroutines-core/common/src/Timeout.kt index 264a2b9d1b..46ab4ae8c8 100644 --- a/kotlinx-coroutines-core/common/src/Timeout.kt +++ b/kotlinx-coroutines-core/common/src/Timeout.kt @@ -64,7 +64,6 @@ public suspend fun withTimeout(timeMillis: Long, block: suspend CoroutineSco * * > Implementation note: how the time is tracked exactly is an implementation detail of the context's [CoroutineDispatcher]. */ -@ExperimentalTime public suspend fun withTimeout(timeout: Duration, block: suspend CoroutineScope.() -> T): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -131,7 +130,6 @@ public suspend fun withTimeoutOrNull(timeMillis: Long, block: suspend Corout * * > Implementation note: how the time is tracked exactly is an implementation detail of the context's [CoroutineDispatcher]. */ -@ExperimentalTime public suspend fun withTimeoutOrNull(timeout: Duration, block: suspend CoroutineScope.() -> T): T? = withTimeoutOrNull(timeout.toDelayMillis(), block) diff --git a/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt b/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt index a5ae63667f..0554142408 100644 --- a/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt +++ b/kotlinx-coroutines-core/common/src/flow/SharingStarted.kt @@ -135,7 +135,6 @@ public fun interface SharingStarted { * are negative. */ @Suppress("FunctionName") -@ExperimentalTime public fun SharingStarted.Companion.WhileSubscribed( stopTimeout: Duration = Duration.ZERO, replayExpiration: Duration = Duration.INFINITE diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt b/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt index e893f44ea5..258dc3eeb1 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt @@ -17,7 +17,6 @@ import kotlin.time.* /* Scaffolding for Knit code examples