Skip to content

Commit 46c0026

Browse files
authored
Merge pull request #2904 from Kotlin/version-1.5.2
Version 1.5.2
2 parents d281a7c + 45547c0 commit 46c0026

File tree

63 files changed

+478
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+478
-622
lines changed

CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 1.5.2
4+
5+
* Kotlin is updated to 1.5.30.
6+
* New native targets for Apple Silicon are introduced.
7+
* Fixed a bug when `onUndeliveredElement` was incorrectly called on a properly received elements on JS (#2826).
8+
* Fixed `Dispatchers.Default` on React Native, it now fully relies on `setTimeout` instead of stub `process.nextTick`. Thanks to @Legion2 (#2843).
9+
* Optimizations of `Mutex` implementation (#2581).
10+
* `Mutex` implementation is made completely lock-free as stated (#2590).
11+
* Various documentation and guides improvements. Thanks to @MasoodFallahpoor and @Pihanya.
12+
313
## Version 1.5.1
414

515
* Atomic `update`, `getAndUpdate`, and `updateAndGet` operations of `MutableStateFlow` (#2720).

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
44
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
5-
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.1)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.1/pom)
6-
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
5+
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.2)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.2/pom)
6+
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.30-blue.svg?logo=kotlin)](http://kotlinlang.org)
77
[![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/)
88

99
Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
10-
This is a companion version for the Kotlin `1.5.20` release.
10+
This is a companion version for the Kotlin `1.5.30` release.
1111

1212
```kotlin
1313
suspend fun main() = coroutineScope {
@@ -83,15 +83,15 @@ Add dependencies (you can also add other modules that you need):
8383
<dependency>
8484
<groupId>org.jetbrains.kotlinx</groupId>
8585
<artifactId>kotlinx-coroutines-core</artifactId>
86-
<version>1.5.1</version>
86+
<version>1.5.2</version>
8787
</dependency>
8888
```
8989

9090
And make sure that you use the latest Kotlin version:
9191

9292
```xml
9393
<properties>
94-
<kotlin.version>1.5.20</kotlin.version>
94+
<kotlin.version>1.5.30</kotlin.version>
9595
</properties>
9696
```
9797

@@ -101,15 +101,15 @@ Add dependencies (you can also add other modules that you need):
101101

102102
```groovy
103103
dependencies {
104-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'
104+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
105105
}
106106
```
107107

108108
And make sure that you use the latest Kotlin version:
109109

110110
```groovy
111111
buildscript {
112-
ext.kotlin_version = '1.5.20'
112+
ext.kotlin_version = '1.5.30'
113113
}
114114
```
115115

@@ -127,7 +127,7 @@ Add dependencies (you can also add other modules that you need):
127127

128128
```groovy
129129
dependencies {
130-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
130+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
131131
}
132132
```
133133

@@ -147,7 +147,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
147147
module as a dependency when using `kotlinx.coroutines` on Android:
148148

149149
```groovy
150-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
150+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
151151
```
152152

153153
This gives you access to the Android [Dispatchers.Main]
@@ -180,7 +180,7 @@ In common code that should get compiled for different platforms, you can add a d
180180
```groovy
181181
commonMain {
182182
dependencies {
183-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
183+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
184184
}
185185
}
186186
```
@@ -192,7 +192,7 @@ Platform-specific dependencies are recommended to be used only for non-multiplat
192192
#### JS
193193

194194
Kotlin/JS version of `kotlinx.coroutines` is published as
195-
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.5.1/jar)
195+
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.5.2/jar)
196196
(follow the link to get the dependency declaration snippet) and as [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) NPM package.
197197

198198
#### Native

docs/topics/exception-handling.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ only downwards. This can easily be demonstrated using the following example:
364364
import kotlinx.coroutines.*
365365

366366
fun main() = runBlocking {
367+
//sampleStart
367368
val supervisor = SupervisorJob()
368369
with(CoroutineScope(coroutineContext + supervisor)) {
369370
// launch the first child -- its exception is ignored for this example (don't do this in practice!)
@@ -389,8 +390,10 @@ fun main() = runBlocking {
389390
supervisor.cancel()
390391
secondChild.join()
391392
}
393+
//sampleEnd
392394
}
393395
```
396+
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
394397

395398
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt).
396399
>
@@ -418,6 +421,7 @@ import kotlin.coroutines.*
418421
import kotlinx.coroutines.*
419422

420423
fun main() = runBlocking {
424+
//sampleStart
421425
try {
422426
supervisorScope {
423427
val child = launch {
@@ -436,8 +440,10 @@ fun main() = runBlocking {
436440
} catch(e: AssertionError) {
437441
println("Caught an assertion error")
438442
}
443+
//sampleEnd
439444
}
440445
```
446+
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
441447

442448
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt).
443449
>
@@ -468,6 +474,7 @@ import kotlin.coroutines.*
468474
import kotlinx.coroutines.*
469475

470476
fun main() = runBlocking {
477+
//sampleStart
471478
val handler = CoroutineExceptionHandler { _, exception ->
472479
println("CoroutineExceptionHandler got $exception")
473480
}
@@ -479,8 +486,10 @@ fun main() = runBlocking {
479486
println("The scope is completing")
480487
}
481488
println("The scope is completed")
489+
//sampleEnd
482490
}
483491
```
492+
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
484493

485494
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt).
486495
>

gradle.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#
44

55
# Kotlin
6-
version=1.5.1-SNAPSHOT
6+
version=1.5.2-SNAPSHOT
77
group=org.jetbrains.kotlinx
8-
kotlin_version=1.5.20
8+
kotlin_version=1.5.30
99

1010
# Dependencies
1111
junit_version=4.12
1212
junit5_version=5.7.0
13-
atomicfu_version=0.16.2
13+
atomicfu_version=0.16.3
1414
knit_version=0.3.0
1515
html_version=0.7.2
1616
lincheck_version=2.14
@@ -22,7 +22,7 @@ rxjava2_version=2.2.8
2222
rxjava3_version=3.0.2
2323
javafx_version=11.0.2
2424
javafx_plugin_version=0.0.8
25-
binary_compatibility_validator_version=0.6.0
25+
binary_compatibility_validator_version=0.7.0
2626
blockhound_version=1.0.2.RELEASE
2727
jna_version=5.5.0
2828

@@ -56,3 +56,4 @@ jekyll_version=4.0
5656
org.gradle.jvmargs=-Xmx4g
5757

5858
kotlin.mpp.enableCompatibilityMetadataVariant=true
59+
kotlin.mpp.stability.nowarn=true

gradle/compile-native-multiplatform.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ kotlin {
2525
addTarget(presets.watchosArm64)
2626
addTarget(presets.watchosX86)
2727
addTarget(presets.watchosX64)
28+
addTarget(presets.iosSimulatorArm64)
29+
addTarget(presets.watchosSimulatorArm64)
30+
addTarget(presets.tvosSimulatorArm64)
31+
addTarget(presets.macosArm64)
2832
}
2933

3034
sourceSets {

gradle/opt-in.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
ext.optInAnnotations = [
6+
"kotlin.RequiresOptIn",
67
"kotlin.experimental.ExperimentalTypeInference",
78
"kotlin.ExperimentalMultiplatform",
89
"kotlinx.coroutines.DelicateCoroutinesApi",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public interface CancellableContinuation<in T> : Continuation<T> {
8181
* Same as [tryResume] but with [onCancellation] handler that called if and only if the value is not
8282
* delivered to the caller because of the dispatch in the process, so that atomicity delivery
8383
* guaranteed can be provided by having a cancellation fallback.
84+
*
85+
* Implementation note: current implementation always returns RESUME_TOKEN or `null`
86+
*
87+
* @suppress **This is unstable API and it is subject to change.**
8488
*/
8589
@InternalCoroutinesApi
8690
public fun tryResume(value: T, idempotent: Any?, onCancellation: ((cause: Throwable) -> Unit)?): Any?

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface CompletableJob : Job {
2121
*
2222
* Subsequent invocations of this function have no effect and always produce `false`.
2323
*
24-
* This function transitions this job into _completed- state if it was not completed or cancelled yet.
24+
* This function transitions this job into _completed_ state if it was not completed or cancelled yet.
2525
* However, that if this job has children, then it transitions into _completing_ state and becomes _complete_
2626
* once all its children are [complete][isCompleted]. See [Job] for details.
2727
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import kotlin.coroutines.intrinsics.*
4949
* * `CoroutineScope()` uses [Dispatchers.Default] for its coroutines.
5050
* * `MainScope()` uses [Dispatchers.Main] for its coroutines.
5151
*
52-
* **The key part of custom usage of `CustomScope` is cancelling it and the end of the lifecycle.**
52+
* **The key part of custom usage of `CustomScope` is cancelling it at the end of the lifecycle.**
5353
* The [CoroutineScope.cancel] extension function shall be used when the entity that was launching coroutines
5454
* is no longer needed. It cancels all the coroutines that might still be running on behalf of it.
5555
*
@@ -185,7 +185,7 @@ public val CoroutineScope.isActive: Boolean
185185
* }
186186
* ```
187187
*
188-
* In top-level code, when launching a concurrent operation operation from a non-suspending context, an appropriately
188+
* In top-level code, when launching a concurrent operation from a non-suspending context, an appropriately
189189
* confined instance of [CoroutineScope] shall be used instead of a `GlobalScope`. See docs on [CoroutineScope] for
190190
* details.
191191
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public interface Job : CoroutineContext.Element {
168168

169169
/**
170170
* Starts coroutine related to this job (if any) if it was not started yet.
171-
* The result `true` if this invocation actually started coroutine or `false`
171+
* The result is `true` if this invocation actually started coroutine or `false`
172172
* if it was already started or completed.
173173
*/
174174
public fun start(): Boolean

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ internal abstract class AbstractSendChannel<E>(
136136
return sendSuspend(element)
137137
}
138138

139+
@Suppress("DEPRECATION")
139140
override fun offer(element: E): Boolean {
140141
// Temporary migration for offer users who rely on onUndeliveredElement
141142
try {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private class ChannelAsFlow<T>(
171171
*/
172172
@Deprecated(
173173
level = DeprecationLevel.WARNING,
174-
message = "'BroadcastChannel' is obsolete and all coreresponding operators are deprecated " +
174+
message = "'BroadcastChannel' is obsolete and all corresponding operators are deprecated " +
175175
"in the favour of StateFlow and SharedFlow"
176176
) // Since 1.5.0, was @FlowPreview, safe to remove in 1.7.0
177177
public fun <T> BroadcastChannel<T>.asFlow(): Flow<T> = flow {
@@ -182,7 +182,7 @@ public fun <T> BroadcastChannel<T>.asFlow(): Flow<T> = flow {
182182
* ### Deprecated
183183
*
184184
* **This API is deprecated.** The [BroadcastChannel] provides a complex channel-like API for hot flows.
185-
* [SharedFlow] is a easier-to-use and more flow-centric API for the same purposes, so using
185+
* [SharedFlow] is an easier-to-use and more flow-centric API for the same purposes, so using
186186
* [shareIn] operator is preferred. It is not a direct replacement, so please
187187
* study [shareIn] documentation to see what kind of shared flow fits your use-case. As a rule of thumb:
188188
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ private class SharedFlowImpl<T>(
469469
// outside of the lock: register dispose on cancellation
470470
emitter?.let { cont.disposeOnCancellation(it) }
471471
// outside of the lock: resume slots if needed
472-
for (cont in resumes) cont?.resume(Unit)
472+
for (r in resumes) r?.resume(Unit)
473473
}
474474

475475
private fun cancelEmitter(emitter: Emitter) = synchronized(this) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public val FlowCollector<*>.coroutineContext: CoroutineContext
8383
get() = noImpl()
8484

8585
@Deprecated(
86-
message = "SharedFlow never completes, so this operator has no effect.",
86+
message = "SharedFlow never completes, so this operator typically has not effect, it can only " +
87+
"catch exceptions from 'onSubscribe' operator",
8788
level = DeprecationLevel.WARNING,
8889
replaceWith = ReplaceWith("this")
8990
)

kotlinx-coroutines-core/common/src/flow/terminal/Collect.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public suspend fun Flow<*>.collect(): Unit = collect(NopCollector)
4444
* .launchIn(uiScope)
4545
* ```
4646
*
47-
* Note that resulting value of [launchIn] is not used the provided scope takes care of cancellation.
47+
* Note that the resulting value of [launchIn] is not used and the provided scope takes care of cancellation.
4848
*/
4949
public fun <T> Flow<T>.launchIn(scope: CoroutineScope): Job = scope.launch {
5050
collect() // tail-call

kotlinx-coroutines-core/common/src/internal/StackTraceRecovery.common.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal expect fun <E: Throwable> recoverStackTrace(exception: E, continuation:
2020
/**
2121
* initCause on JVM, nop on other platforms
2222
*/
23+
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
2324
internal expect fun Throwable.initCause(cause: Throwable)
2425

2526
/**

0 commit comments

Comments
 (0)