Skip to content

Commit 387628b

Browse files
authored
Merge pull request #3815 from Kotlin/roman.efremov/MR/expect-annotations
Make annotations on expect declarations comply with new compiler restriction
2 parents c675e3f + 3c9e856 commit 387628b

11 files changed

+25
-3
lines changed

kotlinx-coroutines-core/api/kotlinx-coroutines-core.api

+5
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ public final class kotlinx/coroutines/DebugKt {
276276
public static final field DEBUG_PROPERTY_VALUE_AUTO Ljava/lang/String;
277277
public static final field DEBUG_PROPERTY_VALUE_OFF Ljava/lang/String;
278278
public static final field DEBUG_PROPERTY_VALUE_ON Ljava/lang/String;
279+
public static final fun getRECOVER_STACK_TRACES ()Z
280+
}
281+
282+
public final class kotlinx/coroutines/DefaultExecutorKt {
283+
public static final fun getDefaultDelay ()Lkotlinx/coroutines/Delay;
279284
}
280285

281286
public abstract interface class kotlinx/coroutines/Deferred : kotlinx/coroutines/Job {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public expect fun CoroutineScope.newCoroutineContext(context: CoroutineContext):
2020
@InternalCoroutinesApi
2121
public expect fun CoroutineContext.newCoroutineContext(addedContext: CoroutineContext): CoroutineContext
2222

23-
@PublishedApi
23+
@PublishedApi // to have unmangled name when using from other modules via suppress
2424
@Suppress("PropertyName")
2525
internal expect val DefaultDelay: Delay
2626

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
package kotlinx.coroutines.internal
66

77
// Ignore JRE requirements for animal-sniffer, compileOnly dependency
8-
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE)
8+
@Target(
9+
AnnotationTarget.FUNCTION,
10+
AnnotationTarget.PROPERTY_GETTER,
11+
AnnotationTarget.PROPERTY_SETTER,
12+
AnnotationTarget.CONSTRUCTOR,
13+
AnnotationTarget.CLASS,
14+
AnnotationTarget.FILE
15+
)
916
@OptionalExpectation
1017
internal expect annotation class IgnoreJreRequirement()

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

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ internal expect suspend inline fun recoverAndThrow(exception: Throwable): Nothin
4040
* The opposite of [recoverStackTrace].
4141
* It is guaranteed that `unwrap(recoverStackTrace(e)) === e`
4242
*/
43+
@PublishedApi // Used from kotlinx-coroutines-test and reactor modules via suppress, not part of ABI
4344
internal expect fun <E: Throwable> unwrap(exception: E): E
4445

4546
internal expect class StackTraceElement

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

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private fun isJsdom() = jsTypeOf(navigator) != UNDEFINED &&
3333
jsTypeOf(navigator.userAgent.match) != UNDEFINED &&
3434
navigator.userAgent.match("\\bjsdom\\b")
3535

36+
@PublishedApi // Used from kotlinx-coroutines-test via suppress, not part of ABI
3637
internal actual val DefaultDelay: Delay
3738
get() = Dispatchers.Default as Delay
3839

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

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ internal actual fun <E: Throwable> recoverStackTrace(exception: E, continuation:
1010
internal actual fun <E: Throwable> recoverStackTrace(exception: E): E = exception
1111
internal actual suspend inline fun recoverAndThrow(exception: Throwable): Nothing = throw exception
1212

13+
@PublishedApi
1314
internal actual fun <E : Throwable> unwrap(exception: E): E = exception
1415

1516
@Suppress("UNUSED")

kotlinx-coroutines-core/jvm/src/Debug.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ internal actual val DEBUG = systemProp(DEBUG_PROPERTY_NAME).let { value ->
7878

7979
// Note: stack-trace recovery is enabled only in debug mode
8080
// @JvmField: Don't use JvmField here to enable R8 optimizations via "assumenosideeffects"
81-
internal actual val RECOVER_STACK_TRACES =
81+
@PublishedApi
82+
internal actual val RECOVER_STACK_TRACES: Boolean =
8283
DEBUG && systemProp(STACKTRACE_RECOVERY_PROPERTY_NAME, true)
8384

8485
// It is used only in debug mode

kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import kotlin.coroutines.*
1010

1111
private val defaultMainDelayOptIn = systemProp("kotlinx.coroutines.main.delay", false)
1212

13+
@PublishedApi
1314
internal actual val DefaultDelay: Delay = initializeDefaultDelay()
1415

1516
private fun initializeDefaultDelay(): Delay {

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

+2
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ internal actual suspend inline fun recoverAndThrow(exception: Throwable): Nothin
157157
}
158158
}
159159

160+
@PublishedApi
160161
@Suppress("NOTHING_TO_INLINE") // Inline for better R8 optimizations
161162
internal actual inline fun <E : Throwable> unwrap(exception: E): E =
162163
if (!RECOVER_STACK_TRACES) exception else unwrapImpl(exception)
163164

165+
@PublishedApi
164166
internal fun <E : Throwable> unwrapImpl(exception: E): E {
165167
val cause = exception.cause
166168
// Fast-path to avoid array cloning

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

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal actual object DefaultExecutor : CoroutineDispatcher(), Delay {
3030

3131
internal expect fun createDefaultDispatcher(): CoroutineDispatcher
3232

33+
@PublishedApi
3334
internal actual val DefaultDelay: Delay = DefaultExecutor
3435

3536
public actual fun CoroutineScope.newCoroutineContext(context: CoroutineContext): CoroutineContext {

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

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import kotlin.coroutines.*
88

99
internal actual fun <E: Throwable> recoverStackTrace(exception: E, continuation: Continuation<*>): E = exception
1010
internal actual fun <E: Throwable> recoverStackTrace(exception: E): E = exception
11+
12+
@PublishedApi
1113
internal actual fun <E : Throwable> unwrap(exception: E): E = exception
1214
internal actual suspend inline fun recoverAndThrow(exception: Throwable): Nothing = throw exception
1315

0 commit comments

Comments
 (0)