Skip to content

Commit 1eeed50

Browse files
authored
Merge pull request #2037 from Kotlin/version-1.3.7
Version 1.3.7
2 parents 583ec6e + b3f7be2 commit 1eeed50

Some content is hidden

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

58 files changed

+519
-134
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
**/.idea/*
22
!/.idea/icon.png
33
!/.idea/vcs.xml
4+
!/.idea/copyright
5+
!/.idea/codeStyleSettings.xml
6+
!/.idea/codeStyles
47
*.iml
58
.gradle
69
.gradletasknamecache

Diff for: .idea/codeStyleSettings.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/codeStyles/Project.xml

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/copyright/kotlinx_coroutines.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: CHANGES.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 1.3.7
4+
5+
* Fixed problem that triggered Android Lint failure (#2004).
6+
* New `Flow.cancellable()` operator for cooperative cancellation (#2026).
7+
* Emissions from `flow` builder now check cancellation status and are properly cancellable (#2026).
8+
* New `currentCoroutineContext` function to use unambiguously in the contexts with `CoroutineScope` in receiver position (#2026).
9+
* `EXACTLY_ONCE` contract support in coroutine builders.
10+
* Various documentation improvements.
11+
312
## Version 1.3.6
413

514
### Flow

Diff for: README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.3.6) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.3.6)
5+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.3.7) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.3.7)
66

77
Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
88
This is a companion version for Kotlin `1.3.71` release.
@@ -84,7 +84,7 @@ Add dependencies (you can also add other modules that you need):
8484
<dependency>
8585
<groupId>org.jetbrains.kotlinx</groupId>
8686
<artifactId>kotlinx-coroutines-core</artifactId>
87-
<version>1.3.6</version>
87+
<version>1.3.7</version>
8888
</dependency>
8989
```
9090

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

103103
```groovy
104104
dependencies {
105-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
105+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
106106
}
107107
```
108108

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

129129
```groovy
130130
dependencies {
131-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6")
131+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7")
132132
}
133133
```
134134

@@ -147,7 +147,7 @@ Make sure that you have either `jcenter()` or `mavenCentral()` in the list of re
147147
Core modules of `kotlinx.coroutines` are also available for
148148
[Kotlin/JS](#js) and [Kotlin/Native](#native).
149149
In common code that should get compiled for different platforms, add dependency to
150-
[`kotlinx-coroutines-core-common`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-common/1.3.6/jar)
150+
[`kotlinx-coroutines-core-common`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-common/1.3.7/jar)
151151
(follow the link to get the dependency declaration snippet).
152152

153153
### Android
@@ -156,7 +156,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
156156
module as dependency when using `kotlinx.coroutines` on Android:
157157

158158
```groovy
159-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6'
159+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
160160
```
161161

162162
This gives you access to Android [Dispatchers.Main]
@@ -172,15 +172,15 @@ For more details see ["Optimization" section for Android](ui/kotlinx-coroutines-
172172
### JS
173173

174174
[Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) version of `kotlinx.coroutines` is published as
175-
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.3.6/jar)
175+
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.3.7/jar)
176176
(follow the link to get the dependency declaration snippet).
177177

178178
You can also use [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) package via NPM.
179179

180180
### Native
181181

182182
[Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html) version of `kotlinx.coroutines` is published as
183-
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.3.6/jar)
183+
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.3.7/jar)
184184
(follow the link to get the dependency declaration snippet).
185185

186186
Only single-threaded code (JS-style) on Kotlin/Native is currently supported.

Diff for: benchmarks/build.gradle.kts

+18-12
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
5+
import me.champeau.gradle.*
6+
import org.jetbrains.kotlin.gradle.tasks.*
67

78
plugins {
89
id("net.ltgt.apt")
910
id("com.github.johnrengelman.shadow")
10-
id("me.champeau.gradle.jmh")
11+
id("me.champeau.gradle.jmh") apply false
1112
}
1213

1314
repositories {
1415
maven("https://repo.typesafe.com/typesafe/releases/")
1516
}
1617

17-
tasks.withType<KotlinCompile>().configureEach {
18-
kotlinOptions.jvmTarget = "1.8"
18+
java {
19+
sourceCompatibility = JavaVersion.VERSION_1_8
20+
targetCompatibility = JavaVersion.VERSION_1_8
1921
}
2022

21-
tasks.compileJmhKotlin {
22-
kotlinOptions.freeCompilerArgs += "-Xjvm-default=enable"
23+
apply(plugin="me.champeau.gradle.jmh")
24+
25+
tasks.named<KotlinCompile>("compileJmhKotlin") {
26+
kotlinOptions {
27+
jvmTarget = "1.8"
28+
freeCompilerArgs += "-Xjvm-default=enable"
29+
}
2330
}
2431

2532
/*
@@ -39,20 +46,20 @@ val removeRedundantFiles = tasks.register<Delete>("removeRedundantFiles") {
3946
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$histoOfLetters\$1\$\$special\$\$inlined\$fold\$1\$1.class")
4047
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleBase\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class")
4148
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleBase\$play\$histoOfLetters\$1\$\$special\$\$inlined\$fold\$1\$1.class")
42-
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble//SaneFlowPlaysScrabble\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class")
49+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/SaneFlowPlaysScrabble\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class")
4350

4451
// Primes
4552
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/misc/Numbers\$\$special\$\$inlined\$filter\$1\$2\$1.class")
4653
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/misc/Numbers\$\$special\$\$inlined\$filter\$1\$1.class")
4754
}
4855

49-
tasks.jmhRunBytecodeGenerator {
56+
tasks.named("jmhRunBytecodeGenerator") {
5057
dependsOn(removeRedundantFiles)
5158
}
5259

5360
// It is better to use the following to run benchmarks, otherwise you may get unexpected errors:
5461
// ./gradlew --no-daemon cleanJmhJar jmh -Pjmh="MyBenchmark"
55-
jmh {
62+
extensions.configure<JMHPluginExtension>("jmh") {
5663
jmhVersion = "1.21"
5764
duplicateClassesStrategy = DuplicatesStrategy.INCLUDE
5865
failOnError = true
@@ -63,7 +70,7 @@ jmh {
6370
// includeTests = false
6471
}
6572

66-
tasks.jmhJar {
73+
tasks.named<Jar>("jmhJar") {
6774
baseName = "benchmarks"
6875
classifier = null
6976
version = null
@@ -76,10 +83,9 @@ dependencies {
7683
compile("io.reactivex.rxjava2:rxjava:2.1.9")
7784
compile("com.github.akarnokd:rxjava2-extensions:0.20.8")
7885

79-
compile("org.openjdk.jmh:jmh-core:1.21")
8086
compile("com.typesafe.akka:akka-actor_2.12:2.5.0")
8187
compile(project(":kotlinx-coroutines-core"))
8288

8389
// add jmh dependency on main
84-
jmhImplementation(sourceSets.main.get().runtimeClasspath)
90+
"jmhImplementation"(sourceSets.main.get().runtimeClasspath)
8591
}

Diff for: benchmarks/src/jmh/kotlin/benchmarks/flow/FlowFlattenMergeBenchmark.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import benchmarks.common.*
88
import kotlinx.coroutines.*
99
import kotlinx.coroutines.flow.*
1010
import org.openjdk.jmh.annotations.*
11-
import java.util.concurrent.*
11+
import java.util.concurrent.TimeUnit
1212

1313
/**
1414
* Benchmark to measure performance of [kotlinx.coroutines.flow.FlowKt.flattenMerge].

Diff for: benchmarks/src/jmh/kotlin/benchmarks/flow/NumbersBenchmark.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import io.reactivex.functions.*
1111
import kotlinx.coroutines.*
1212
import kotlinx.coroutines.flow.*
1313
import org.openjdk.jmh.annotations.*
14-
import java.util.concurrent.*
14+
import java.util.concurrent.TimeUnit
15+
import java.util.concurrent.Callable
1516

1617
@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
1718
@Measurement(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)

Diff for: benchmarks/src/jmh/kotlin/benchmarks/flow/TakeBenchmark.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package benchmarks.flow
77
import kotlinx.coroutines.*
88
import kotlinx.coroutines.flow.*
99
import org.openjdk.jmh.annotations.*
10-
import java.util.concurrent.*
10+
import java.util.concurrent.TimeUnit
1111
import java.util.concurrent.CancellationException
1212
import kotlin.coroutines.*
1313
import kotlin.coroutines.intrinsics.*

Diff for: benchmarks/src/jmh/kotlin/benchmarks/flow/scrabble/FlowPlaysScrabbleBase.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.*
99
import org.openjdk.jmh.annotations.*
1010
import java.lang.Long.max
1111
import java.util.*
12-
import java.util.concurrent.*
12+
import java.util.concurrent.TimeUnit
1313
import kotlin.math.*
1414

1515
@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)

Diff for: benchmarks/src/jmh/kotlin/benchmarks/flow/scrabble/SaneFlowPlaysScrabble.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.*
99
import org.openjdk.jmh.annotations.*
1010
import java.lang.Long.*
1111
import java.util.*
12-
import java.util.concurrent.*
12+
import java.util.concurrent.TimeUnit
1313

1414
@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
1515
@Measurement(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)

Diff for: build.gradle

+1-14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import org.jetbrains.kotlin.konan.target.HostManager
55

6+
apply plugin: 'jdk-convention'
67
apply from: rootProject.file("gradle/experimental.gradle")
78

89
def rootModule = "kotlinx.coroutines"
@@ -69,7 +70,6 @@ buildscript {
6970
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
7071
classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
7172
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
72-
classpath "org.openjfx:javafx-plugin:$javafx_plugin_version"
7373
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version"
7474

7575
// JMH plugins
@@ -264,22 +264,9 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
264264
// Report Kotlin compiler version when building project
265265
println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
266266

267-
// --------------- Publish only from under JDK11+ ---------------
268-
task checkJdkForPublish {
269-
doFirst {
270-
if (JavaVersionKt.javaVersionMajor < 11) {
271-
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${JavaVersionKt.javaVersion}")
272-
}
273-
}
274-
}
275-
276267
// --------------- Configure sub-projects that are published ---------------
277268
def publishTasks = getTasksByName("publish", true) + getTasksByName("publishNpm", true)
278269

279-
publishTasks.each {
280-
it.dependsOn checkJdkForPublish
281-
}
282-
283270
task deploy(dependsOn: publishTasks)
284271

285272
apply plugin: 'base'

Diff for: buildSrc/src/main/kotlin/Idea.kt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Idea {
2+
val active: Boolean
3+
get() = System.getProperty("idea.active") == "true"
4+
}

Diff for: buildSrc/src/main/kotlin/JavaVersion.kt

-7
This file was deleted.

Diff for: buildSrc/src/main/kotlin/jdk-convention.gradle.kts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.gradle.api.JavaVersion
2+
3+
if (!JavaVersion.current().isJava11Compatible) {
4+
val message = "Project required JDK 11+, but found ${JavaVersion.current()}"
5+
if (Idea.active) {
6+
logger.error(message)
7+
} else {
8+
throw GradleException(message)
9+
}
10+
}

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
# Kotlin
6-
version=1.3.6-SNAPSHOT
6+
version=1.3.7-SNAPSHOT
77
group=org.jetbrains.kotlinx
88
kotlin_version=1.3.71
99

Diff for: integration/kotlinx-coroutines-jdk8/src/time/Time.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/*
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4+
@file:OptIn(ExperimentalContracts::class)
5+
46
package kotlinx.coroutines.time
57

68
import kotlinx.coroutines.*
79
import kotlinx.coroutines.flow.*
810
import kotlinx.coroutines.selects.*
911
import java.time.*
1012
import java.time.temporal.*
13+
import kotlin.contracts.*
1114

1215
/**
1316
* "java.time" adapter method for [kotlinx.coroutines.delay].
@@ -35,8 +38,12 @@ public fun <R> SelectBuilder<R>.onTimeout(duration: Duration, block: suspend ()
3538
/**
3639
* "java.time" adapter method for [kotlinx.coroutines.withTimeout].
3740
*/
38-
public suspend fun <T> withTimeout(duration: Duration, block: suspend CoroutineScope.() -> T): T =
39-
kotlinx.coroutines.withTimeout(duration.coerceToMillis(), block)
41+
public suspend fun <T> withTimeout(duration: Duration, block: suspend CoroutineScope.() -> T): T {
42+
contract {
43+
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
44+
}
45+
return kotlinx.coroutines.withTimeout(duration.coerceToMillis(), block)
46+
}
4047

4148
/**
4249
* "java.time" adapter method for [kotlinx.coroutines.withTimeoutOrNull].

Diff for: kotlinx-coroutines-core/api/kotlinx-coroutines-core.api

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ public final class kotlinx/coroutines/CoroutineScopeKt {
214214
public static synthetic fun cancel$default (Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Ljava/lang/Throwable;ILjava/lang/Object;)V
215215
public static synthetic fun cancel$default (Lkotlinx/coroutines/CoroutineScope;Ljava/util/concurrent/CancellationException;ILjava/lang/Object;)V
216216
public static final fun coroutineScope (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
217+
public static final fun currentCoroutineContext (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
217218
public static final fun ensureActive (Lkotlinx/coroutines/CoroutineScope;)V
218219
public static final fun isActive (Lkotlinx/coroutines/CoroutineScope;)Z
219220
public static final fun plus (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/CoroutineScope;
@@ -873,6 +874,7 @@ public final class kotlinx/coroutines/flow/FlowKt {
873874
public static final fun buffer (Lkotlinx/coroutines/flow/Flow;I)Lkotlinx/coroutines/flow/Flow;
874875
public static synthetic fun buffer$default (Lkotlinx/coroutines/flow/Flow;IILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
875876
public static final fun callbackFlow (Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
877+
public static final fun cancellable (Lkotlinx/coroutines/flow/Flow;)Lkotlinx/coroutines/flow/Flow;
876878
public static final fun catch (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/flow/Flow;
877879
public static final fun channelFlow (Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
878880
public static final fun collect (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;

0 commit comments

Comments
 (0)