Skip to content

Commit e6e8239

Browse files
committed
Experimental annotation revisit:
* Mark our API annotation as experimental with corresponding warning or error * Get rid of workaround for new inference bug * Migrate to compiler arguments instead of annotations
1 parent 1f7b2d8 commit e6e8239

File tree

24 files changed

+34
-97
lines changed

24 files changed

+34
-97
lines changed

build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,24 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
170170
}
171171
}
172172
}
173-
173+
174174
if (platform == "jvm") {
175175
dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
176176
// dump declarations from main JVM module for binary-compatibility-validator
177177
compileKotlin {
178178
kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
179179
}
180180
}
181+
182+
183+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
184+
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental",
185+
"-Xuse-experimental=kotlin.experimental.ExperimentalTypeInference",
186+
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
187+
"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
188+
"-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi"]
189+
190+
}
181191
}
182192

183193
// main deployment task

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ package kotlinx.coroutines
1111
* the semantics of their behavior may change in some way that may break some code.
1212
*/
1313
@MustBeDocumented
14-
@Retention(value = AnnotationRetention.SOURCE)
15-
// todo: Experimental WARNING
14+
@Retention(value = AnnotationRetention.BINARY)
15+
@Experimental(level = Experimental.Level.WARNING)
1616
public annotation class ExperimentalCoroutinesApi
1717

1818
/**
@@ -22,8 +22,8 @@ public annotation class ExperimentalCoroutinesApi
2222
* so they cannot be deprecated right away.
2323
*/
2424
@MustBeDocumented
25-
@Retention(value = AnnotationRetention.SOURCE)
26-
// todo: Experimental WARNING
25+
@Retention(value = AnnotationRetention.BINARY)
26+
@Experimental(level = Experimental.Level.WARNING)
2727
public annotation class ObsoleteCoroutinesApi
2828

2929
/**
@@ -33,6 +33,6 @@ public annotation class ObsoleteCoroutinesApi
3333
*
3434
* @suppress **This an internal API and should not be used from general code.**
3535
*/
36-
@Retention(value = AnnotationRetention.SOURCE)
37-
// todo: Experimental ERROR
36+
@Retention(value = AnnotationRetention.BINARY)
37+
@Experimental(level = Experimental.Level.ERROR)
3838
public annotation class InternalCoroutinesApi

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
@file:JvmMultifileClass
66
@file:JvmName("BuildersKt")
7-
@file:UseExperimental(ExperimentalTypeInference::class)
87

98
package kotlinx.coroutines
109

@@ -14,7 +13,6 @@ import kotlinx.coroutines.intrinsics.*
1413
import kotlinx.coroutines.selects.*
1514
import kotlin.coroutines.*
1615
import kotlin.coroutines.intrinsics.*
17-
import kotlin.experimental.*
1816

1917
// --------------- launch ---------------
2018

@@ -43,7 +41,6 @@ import kotlin.experimental.*
4341
* @param start coroutine start option. The default value is [CoroutineStart.DEFAULT].
4442
* @param block the coroutine code which will be invoked in the context of the provided scope.
4543
**/
46-
@BuilderInference
4744
public fun CoroutineScope.launch(
4845
context: CoroutineContext = EmptyCoroutineContext,
4946
start: CoroutineStart = CoroutineStart.DEFAULT,
@@ -78,7 +75,6 @@ public fun CoroutineScope.launch(
7875
* @param start coroutine start option. The default value is [CoroutineStart.DEFAULT].
7976
* @param block the coroutine code.
8077
*/
81-
@BuilderInference
8278
public fun <T> CoroutineScope.async(
8379
context: CoroutineContext = EmptyCoroutineContext,
8480
start: CoroutineStart = CoroutineStart.DEFAULT,

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines
86

97
import kotlin.coroutines.*
10-
import kotlin.experimental.*
118

12-
@BuilderInference
139
public expect fun CoroutineScope.newCoroutineContext(context: CoroutineContext): CoroutineContext
1410

1511
internal expect fun createDefaultDispatcher(): CoroutineDispatcher

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines
86

97
import kotlinx.coroutines.internal.*
108
import kotlinx.coroutines.intrinsics.*
119
import kotlin.coroutines.intrinsics.*
1210
import kotlin.coroutines.*
13-
import kotlin.experimental.*
1411

1512
/**
1613
* Defines a scope for new coroutines. Every coroutine builder
@@ -74,7 +71,6 @@ public interface CoroutineScope {
7471
*
7572
* This is a shorthand for `CoroutineScope(thisScope + context)`.
7673
*/
77-
@BuilderInference
7874
public operator fun CoroutineScope.plus(context: CoroutineContext): CoroutineScope =
7975
ContextScope(coroutineContext + context)
8076

@@ -94,7 +90,6 @@ public operator fun CoroutineScope.plus(context: CoroutineContext): CoroutineSco
9490
* [isActive][kotlinx.coroutines.isActive] and [Job.isActive].
9591
*/
9692
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
97-
@BuilderInference
9893
public val CoroutineScope.isActive: Boolean
9994
get() = coroutineContext[Job]?.isActive ?: true
10095

@@ -164,7 +159,7 @@ object GlobalScope : CoroutineScope {
164159
*/
165160
public suspend fun <R> coroutineScope(block: suspend CoroutineScope.() -> R): R =
166161
suspendCoroutineUninterceptedOrReturn { uCont ->
167-
val coroutine = ScopeCoroutine<R>(uCont.context, uCont)
162+
val coroutine = ScopeCoroutine(uCont.context, uCont)
168163
coroutine.startUndispatchedOrReturn(coroutine, block)
169164
}
170165

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines
86

9-
import kotlinx.coroutines.intrinsics.*
107
import kotlinx.coroutines.selects.*
11-
import kotlin.coroutines.*
12-
import kotlin.experimental.*
138

149
/**
1510
* Deferred value is a non-blocking cancellable future &mdash; it is a [Job] that has a result.

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines.channels
86

97
import kotlinx.coroutines.*
108
import kotlinx.coroutines.channels.Channel.Factory.CONFLATED
119
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
1210
import kotlinx.coroutines.intrinsics.*
1311
import kotlin.coroutines.*
14-
import kotlin.experimental.*
1512

1613
/**
1714
* Broadcasts all elements of the channel.
@@ -65,7 +62,6 @@ fun <E> ReceiveChannel<E>.broadcast(
6562
* @param onCompletion optional completion handler for the producer coroutine (see [Job.invokeOnCompletion]).
6663
* @param block the coroutine code.
6764
*/
68-
@BuilderInference
6965
public fun <E> CoroutineScope.broadcast(
7066
context: CoroutineContext = EmptyCoroutineContext,
7167
capacity: Int = 1,

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines.channels
86

97
import kotlinx.coroutines.*
10-
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
118
import kotlin.coroutines.*
12-
import kotlin.experimental.*
139

1410
/**
1511
* Scope for [produce][CoroutineScope.produce] coroutine builder.
@@ -61,7 +57,6 @@ public interface ProducerScope<in E> : CoroutineScope, SendChannel<E> {
6157
* @param block the coroutine code.
6258
*/
6359
@ExperimentalCoroutinesApi
64-
@BuilderInference
6560
public fun <E> CoroutineScope.produce(
6661
context: CoroutineContext = EmptyCoroutineContext,
6762
capacity: Int = 0,
@@ -78,7 +73,6 @@ public fun <E> CoroutineScope.produce(
7873
* @suppress **This an internal API and should not be used from general code.**
7974
* onCompletion parameter will be redesigned.
8075
*/
81-
@BuilderInference
8276
@InternalCoroutinesApi
8377
public fun <E> CoroutineScope.produce(
8478
context: CoroutineContext = EmptyCoroutineContext,

core/kotlinx-coroutines-core/src/CoroutineContext.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines
86

97
import kotlinx.coroutines.internal.*
108
import kotlinx.coroutines.scheduling.*
119
import java.util.concurrent.atomic.*
1210
import kotlin.coroutines.*
13-
import kotlin.experimental.*
1411

1512
private val COROUTINE_ID = AtomicLong()
1613

@@ -55,7 +52,6 @@ internal actual fun createDefaultDispatcher(): CoroutineDispatcher =
5552
* **Note: This is an experimental api.**
5653
* Behavior of this function may change in the future with respect to its support for debugging facilities.
5754
*/
58-
@BuilderInference
5955
@ExperimentalCoroutinesApi
6056
public actual fun CoroutineScope.newCoroutineContext(context: CoroutineContext): CoroutineContext {
6157
val combined = coroutineContext + context

core/kotlinx-coroutines-core/src/channels/Actor.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:UseExperimental(ExperimentalTypeInference::class)
6-
75
package kotlinx.coroutines.channels
86

97
import kotlinx.coroutines.*
10-
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
118
import kotlinx.coroutines.intrinsics.*
129
import kotlinx.coroutines.selects.*
1310
import kotlin.coroutines.*
14-
import kotlin.experimental.*
1511

1612
/**
1713
* Scope for [actor][GlobalScope.actor] coroutine builder.
@@ -109,7 +105,6 @@ public interface ActorScope<E> : CoroutineScope, ReceiveChannel<E> {
109105
* @param block the coroutine code.
110106
*/
111107
@ObsoleteCoroutinesApi
112-
@BuilderInference
113108
public fun <E> CoroutineScope.actor(
114109
context: CoroutineContext = EmptyCoroutineContext,
115110
capacity: Int = 0,

0 commit comments

Comments
 (0)