Merge branch 'master' into develop
diff --git a/CHANGES.md b/CHANGES.md
index 1135402..43045c3 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,12 @@
 # Change log for kotlinx.coroutines
 
+## Version 1.1.1
+
+* Maintenance release, no changes in the codebase
+* Kotlin is updated to 1.3.20
+* Gradle is updated to 4.10
+* Native module is published with Gradle metadata v0.4 
+
 ## Version 1.1.0
 
 * Kotlin version updated to 1.3.11.
diff --git a/README.md b/README.md
index 26ae72d..94417dc 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,10 @@
 
 [![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
 [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
-[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.1.0) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.1.0)
+[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.1.1) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.1.1)
 
 Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
-This is a companion version for Kotlin `1.3.11` release.
+This is a companion version for Kotlin `1.3.20` release.
 
 **NOTE**: `0.30.2` was the last release with Kotlin 1.2 and experimental coroutines.
 See [COMPATIBILITY.md](COMPATIBILITY.md) for details of migration onto the stable Kotlin 1.3 coroutines.
@@ -74,7 +74,7 @@
 <dependency>
     <groupId>org.jetbrains.kotlinx</groupId>
     <artifactId>kotlinx-coroutines-core</artifactId>
-    <version>1.1.0</version>
+    <version>1.1.1</version>
 </dependency>
 ```
 
@@ -82,7 +82,7 @@
 
 ```xml
 <properties>
-    <kotlin.version>1.3.11</kotlin.version>
+    <kotlin.version>1.3.20</kotlin.version>
 </properties>
 ```
 
@@ -92,7 +92,7 @@
 
 ```groovy
 dependencies {
-    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
+    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
 }
 ```
 
@@ -100,7 +100,7 @@
 
 ```groovy
 buildscript {
-    ext.kotlin_version = '1.3.11'
+    ext.kotlin_version = '1.3.20'
 }
 ```
 
@@ -118,7 +118,7 @@
 
 ```groovy
 dependencies {
-    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0")
+    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1")
 }
 ```
 
@@ -126,7 +126,7 @@
 
 ```groovy
 plugins {
-    kotlin("jvm") version "1.3.11"
+    kotlin("jvm") version "1.3.20"
 }
 ```
 
@@ -146,7 +146,7 @@
 module as dependency when using `kotlinx.coroutines` on Android:
 
 ```groovy
-implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'
+implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
 ```
 This gives you access to Android [Dispatchers.Main](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-android/kotlinx.coroutines.android/kotlinx.coroutines.-dispatchers/index.html)
 coroutine dispatcher and also makes sure that in case of crashed coroutine with unhandled exception this
diff --git a/build.gradle b/build.gradle
index c83fea9..a6e81b7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -12,6 +12,7 @@
     }
     repositories {
         jcenter()
+        maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:1907319/artifacts/content/maven" }
         maven { url "https://kotlin.bintray.com/kotlinx" }
         maven { url "https://kotlin.bintray.com/kotlin-dev" }
         maven { url "https://kotlin.bintray.com/kotlin-eap" }
@@ -63,6 +64,7 @@
             google()
         }
         jcenter()
+        maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:1907319/artifacts/content/maven" }
         maven { url "https://kotlin.bintray.com/kotlin-dev" }
         maven { url "https://kotlin.bintray.com/kotlin-eap" }
         maven { url "https://kotlin.bintray.com/kotlinx" }
diff --git a/core/kotlinx-coroutines-core/test/CancellableContinuationJvmTest.kt b/core/kotlinx-coroutines-core/test/CancellableContinuationJvmTest.kt
index 82d17ed..296dc81 100644
--- a/core/kotlinx-coroutines-core/test/CancellableContinuationJvmTest.kt
+++ b/core/kotlinx-coroutines-core/test/CancellableContinuationJvmTest.kt
@@ -16,7 +16,7 @@
     private suspend fun checkToString() {
         suspendCancellableCoroutine<Unit> {
             it.resume(Unit)
-            assertTrue(it.toString().contains("kotlinx/coroutines/CancellableContinuationJvmTest.checkToString(CancellableContinuationJvmTest.kt"))
+            assertTrue(it.toString().contains("kotlinx.coroutines.CancellableContinuationJvmTest.checkToString(CancellableContinuationJvmTest.kt"))
         }
     }
 }
diff --git a/core/kotlinx-coroutines-debug/README.md b/core/kotlinx-coroutines-debug/README.md
index fce32bb..b9cc094 100644
--- a/core/kotlinx-coroutines-debug/README.md
+++ b/core/kotlinx-coroutines-debug/README.md
@@ -18,99 +18,83 @@
 Add `kotlinx-coroutines-debug` to your project test dependencies:
 ```
 dependencies {
-    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.1.0'
+    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.1.1'
 }
 ```
 
 ### Using as JVM agent
 
 It is possible to use this module as a standalone JVM agent to enable debug probes on the application startup.
-You can run your application with an additional argument: `-javaagent:kotlinx-coroutines-debug-1.1.0.jar`.
+You can run your application with an additional argument: `-javaagent:kotlinx-coroutines-debug-1.1.1.jar`.
 Additionally, on Linux and Mac OS X you can use `kill -5 $pid` command in order to force your application to print all alive coroutines.
 
 
 ### Example of usage
 
-Capabilities of this module can be demonstrated by the following example:
+Capabilities of this module can be demonstrated by the following example 
+(runnable code is [here](test/Example.kt)):
+
 ```kotlin
-class Computation {
-    public fun computeValue(): Deferred<String> = GlobalScope.async {
-        val firstPart = computeFirstPart()
-        val secondPart = computeSecondPart()
-
-        combineResults(firstPart, secondPart)
-    }
-
-    private suspend fun combineResults(firstPart: Deferred<String>, secondPart: Deferred<String>): String {
-        return firstPart.await() + secondPart.await()
-    }
-
-
-    private suspend fun CoroutineScope.computeFirstPart() = async {
-        delay(5000)
-        "4"
-    }
-
-    private suspend fun CoroutineScope.computeSecondPart() = async {
-        delay(5000)
-        "2"
-    }
+suspend fun computeValue(): String = coroutineScope {
+    val one = async { computeOne() }
+    val two = async { computeTwo() }
+    combineResults(one, two)
 }
 
-fun main(args: Array<String>) = runBlocking {
-    DebugProbes.install()
-    val computation = Computation()
-    val deferred = computation.computeValue()
+suspend fun combineResults(one: Deferred<String>, two: Deferred<String>): String =
+    one.await() + two.await()
 
+suspend fun computeOne(): String {
+    delay(5000)
+    return "4"
+}
+
+suspend fun computeTwo(): String {
+    delay(5000)
+    return "2"
+}
+
+fun main() = runBlocking {
+    DebugProbes.install()
+    val deferred = async { computeValue() }
     // Delay for some time
     delay(1000)
-
+    // Dump running coroutines
     DebugProbes.dumpCoroutines()
-
     println("\nDumping only deferred")
     DebugProbes.printJob(deferred)
 }
 ```
 
 Printed result will be:
+
 ```
 Coroutines dump 2018/11/12 21:44:02
 
-Coroutine "coroutine#2":DeferredCoroutine{Active}@1b26f7b2, state: SUSPENDED
+Coroutine "coroutine#2":DeferredCoroutine{Active}@289d1c02, state: SUSPENDED
 	at kotlinx.coroutines.DeferredCoroutine.await$suspendImpl(Builders.common.kt:99)
-	at Computation.combineResults(Example.kt:18)
-	at Computation$computeValue$1.invokeSuspend(Example.kt:14)
+	at ExampleKt.combineResults(Example.kt:11)
+	at ExampleKt$computeValue$2.invokeSuspend(Example.kt:7)
+	at ExampleKt$main$1$deferred$1.invokeSuspend(Example.kt:25)
 	(Coroutine creation stacktrace)
 	at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.createCoroutineUnintercepted(IntrinsicsJvm.kt:116)
-	at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:23)
-	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
-	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:160)
-	at kotlinx.coroutines.BuildersKt__Builders_commonKt.async(Builders.common.kt:88)
-	at kotlinx.coroutines.BuildersKt.async(Unknown Source)
-	at kotlinx.coroutines.BuildersKt__Builders_commonKt.async$default(Builders.common.kt:81)
+	at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:25)
 	at kotlinx.coroutines.BuildersKt.async$default(Unknown Source)
-	at Computation.computeValue(Example.kt:10)
-	at ExampleKt$main$1.invokeSuspend(Example.kt:36)
+	at ExampleKt$main$1.invokeSuspend(Example.kt:25)
 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
-	at kotlinx.coroutines.DispatchedTask$DefaultImpls.run(Dispatched.kt:237)
-	at kotlinx.coroutines.DispatchedContinuation.run(Dispatched.kt:81)
-	at kotlinx.coroutines.EventLoopBase.processNextEvent(EventLoop.kt:123)
-	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:69)
-	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
-	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
-	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
+	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
 	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
-	at ExampleKt.main(Example.kt:33)
+	at ExampleKt.main(Example.kt:23)
+	at ExampleKt.main(Example.kt)
 
 ... More coroutines here ...
 
 Dumping only deferred
 "coroutine#2":DeferredCoroutine{Active}, continuation is SUSPENDED at line kotlinx.coroutines.DeferredCoroutine.await$suspendImpl(Builders.common.kt:99)
-	"coroutine#3":DeferredCoroutine{Active}, continuation is SUSPENDED at line Computation$computeFirstPart$2.invokeSuspend(Example.kt:23)
-	"coroutine#4":DeferredCoroutine{Active}, continuation is SUSPENDED at line Computation$computeSecondPart$2.invokeSuspend(Example.kt:28)
+			"coroutine#3":DeferredCoroutine{Active}, continuation is SUSPENDED at line ExampleKt.computeOne(Example.kt:14)
+		"coroutine#4":DeferredCoroutine{Active}, continuation is SUSPENDED at line ExampleKt.computeTwo(Example.kt:19)
 ```
 
-
 ### Status of the API
 
 API is purely experimental and it is not guaranteed that it won't be changed (while it is marked as `@ExperimentalCoroutinesApi`).
diff --git a/core/kotlinx-coroutines-debug/test/Example.kt b/core/kotlinx-coroutines-debug/test/Example.kt
new file mode 100644
index 0000000..8a0944c
--- /dev/null
+++ b/core/kotlinx-coroutines-debug/test/Example.kt
@@ -0,0 +1,32 @@
+import kotlinx.coroutines.*
+import kotlinx.coroutines.debug.*
+
+suspend fun computeValue(): String = coroutineScope {
+    val one = async { computeOne() }
+    val two = async { computeTwo() }
+    combineResults(one, two)
+}
+
+suspend fun combineResults(one: Deferred<String>, two: Deferred<String>): String =
+    one.await() + two.await()
+
+suspend fun computeOne(): String {
+    delay(5000)
+    return "4"
+}
+
+suspend fun computeTwo(): String {
+    delay(5000)
+    return "2"
+}
+
+fun main() = runBlocking {
+    DebugProbes.install()
+    val deferred = async { computeValue() }
+    // Delay for some time
+    delay(1000)
+    // Dump running coroutines
+    DebugProbes.dumpCoroutines()
+    println("\nDumping only deferred")
+    DebugProbes.printJob(deferred)
+}
\ No newline at end of file
diff --git a/core/kotlinx-coroutines-test/README.md b/core/kotlinx-coroutines-test/README.md
index 08fbdc1..a461bf4 100644
--- a/core/kotlinx-coroutines-test/README.md
+++ b/core/kotlinx-coroutines-test/README.md
@@ -7,7 +7,7 @@
 Add `kotlinx-coroutines-test` to your project test dependencies:
 ```
 dependencies {
-    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.1.0'
+    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.1.1'
 }
 ```
 
diff --git a/gradle.properties b/gradle.properties
index 1072552..de04562 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,16 +1,16 @@
 # Kotlin
-version=1.1.0-SNAPSHOT
+version=1.1.1-SNAPSHOT
 group=org.jetbrains.kotlinx
-kotlin_version=1.3.11
-kotlin_native_version=1.3.11
+kotlin_version=1.3.20
+kotlin_native_version=1.3.20
 
 # Dependencies
 junit_version=4.12
-atomicFU_version=0.12.0
+atomicFU_version=0.12.1
 html_version=0.6.8
 lincheck_version=2.0
 dokka_version=0.9.16-rdev-2-mpp-hacks
-bintray_version=1.8.2-SNAPSHOT
+bintray_version=1.8.4-jetbrains-5
 byte_buddy_version=1.9.3
 artifactory_plugin_version=4.7.3
 
diff --git a/gradle/publish-bintray.gradle b/gradle/publish-bintray.gradle
index 23c38bd..64e62e5 100644
--- a/gradle/publish-bintray.gradle
+++ b/gradle/publish-bintray.gradle
@@ -117,10 +117,7 @@
 if (!isNative()) {
     afterEvaluate {
         publishing.publications.each { pub ->
-            pub.gradleModuleMetadataFile = null
-            tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
-                onlyIf { false }
-            }
+            pub.moduleDescriptorGenerator = null
         }
     }
 }
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 91ca28c..28861d2 100644
--- a/gradle/wrapper/gradle-wrapper.jar
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 16d2805..115e6ac 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
diff --git a/integration/kotlinx-coroutines-jdk8/src/future/Future.kt b/integration/kotlinx-coroutines-jdk8/src/future/Future.kt
index fe02974..6c59a08 100644
--- a/integration/kotlinx-coroutines-jdk8/src/future/Future.kt
+++ b/integration/kotlinx-coroutines-jdk8/src/future/Future.kt
@@ -95,7 +95,7 @@
         } catch (e: Throwable) {
             // unwrap original cause from ExecutionException
             val original = (e as? ExecutionException)?.cause ?: e
-            CompletableDeferred<T>().also { it.cancel(original) }
+            CompletableDeferred<T>().also { it.completeExceptionally(original) }
         }
     }
     val result = CompletableDeferred<T>()
@@ -103,7 +103,7 @@
         if (exception == null) {
             result.complete(value)
         } else {
-            result.cancel(exception)
+            result.completeExceptionally(exception)
         }
     }
     if (this is Future<*>) result.cancelFutureOnCompletion(this)
diff --git a/native/README.md b/native/README.md
index 897a07e..031b433 100644
--- a/native/README.md
+++ b/native/README.md
@@ -42,7 +42,7 @@
 }
 
 dependencies {
-    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.1.0'
+    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.1.1'
 }
 
 sourceSets {
diff --git a/native/kotlinx-coroutines-core-native/src/internal/Concurrent.kt b/native/kotlinx-coroutines-core-native/src/internal/Concurrent.kt
index 9e6fd65..546d6af 100644
--- a/native/kotlinx-coroutines-core-native/src/internal/Concurrent.kt
+++ b/native/kotlinx-coroutines-core-native/src/internal/Concurrent.kt
@@ -18,4 +18,4 @@
 internal actual fun <E> identitySet(expectedSize: Int): MutableSet<E> = HashSet()
 
 @Suppress("ACTUAL_WITHOUT_EXPECT")
-internal actual typealias SharedImmutable = kotlin.native.SharedImmutable
+internal actual typealias SharedImmutable = kotlin.native.concurrent.SharedImmutable
diff --git a/native/kotlinx-coroutines-core-native/src/internal/ThreadLocal.kt b/native/kotlinx-coroutines-core-native/src/internal/ThreadLocal.kt
index 420e0d2..7214bba 100644
--- a/native/kotlinx-coroutines-core-native/src/internal/ThreadLocal.kt
+++ b/native/kotlinx-coroutines-core-native/src/internal/ThreadLocal.kt
@@ -6,7 +6,7 @@
 import kotlin.native.concurrent.*
 
 @Suppress("ACTUAL_WITHOUT_EXPECT")
-internal actual typealias NativeThreadLocal = kotlin.native.ThreadLocal
+internal actual typealias NativeThreadLocal = kotlin.native.concurrent.ThreadLocal
 
 internal actual class CommonThreadLocal<T> actual constructor() {
     private var value: T? = null
diff --git a/ui/coroutines-guide-ui.md b/ui/coroutines-guide-ui.md
index 0f5f5fa..223af58 100644
--- a/ui/coroutines-guide-ui.md
+++ b/ui/coroutines-guide-ui.md
@@ -165,7 +165,7 @@
 `app/build.gradle` file:
 
 ```groovy
-implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0"
+implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1"
 ```
 
 You can clone [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) project from GitHub onto your 
@@ -659,7 +659,7 @@
 for execution later. All UI dispatchers in `kotlinx.coroutines` are implemented this way. Why so? 
 
 Basically, the choice here is between "JS-style" asynchronous approach (async actions
-are always postponed to be executed later in the even dispatch thread) and "C#-style" approach
+are always postponed to be executed later in the event dispatch thread) and "C#-style" approach
 (async actions are executed in the invoker thread until the first suspension point).
 While, C# approach seems to be more efficient, it ends up with recommendations like
 "use `yield` if you need to ....". This is error-prone. JS-style approach is more consistent
diff --git a/ui/kotlinx-coroutines-android/animation-app/gradle.properties b/ui/kotlinx-coroutines-android/animation-app/gradle.properties
index fad72f9..c2dde35 100644
--- a/ui/kotlinx-coroutines-android/animation-app/gradle.properties
+++ b/ui/kotlinx-coroutines-android/animation-app/gradle.properties
@@ -18,6 +18,6 @@
 
 kotlin.coroutines=enable
 
-kotlin_version=1.3.11
-coroutines_version=1.1.0
+kotlin_version=1.3.20
+coroutines_version=1.1.1
 
diff --git a/ui/kotlinx-coroutines-android/example-app/gradle.properties b/ui/kotlinx-coroutines-android/example-app/gradle.properties
index fad72f9..c2dde35 100644
--- a/ui/kotlinx-coroutines-android/example-app/gradle.properties
+++ b/ui/kotlinx-coroutines-android/example-app/gradle.properties
@@ -18,6 +18,6 @@
 
 kotlin.coroutines=enable
 
-kotlin_version=1.3.11
-coroutines_version=1.1.0
+kotlin_version=1.3.20
+coroutines_version=1.1.1