Skip to content

Commit 3f0a860

Browse files
committed
Preserve source-level compatibility with Java
1 parent 088f61f commit 3f0a860

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public final class kotlinx/coroutines/BuildersKt {
3030
public static final fun withContext (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
3131
}
3232

33+
public final class kotlinx/coroutines/Builders_concurrentKt {
34+
public static final fun runBlocking (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
35+
public static synthetic fun runBlocking$default (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/lang/Object;
36+
}
37+
3338
public abstract interface class kotlinx/coroutines/CancellableContinuation : kotlin/coroutines/Continuation {
3439
public abstract fun cancel (Ljava/lang/Throwable;)Z
3540
public abstract fun completeResume (Ljava/lang/Object;)V

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

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:JvmMultifileClass
2-
@file:JvmName("BuildersKt")
31
@file:Suppress("LEAKED_IN_PLACE_LAMBDA", "WRONG_INVOCATION_KIND")
42

53
package kotlinx.coroutines
@@ -8,8 +6,6 @@ import kotlin.contracts.ExperimentalContracts
86
import kotlin.contracts.InvocationKind
97
import kotlin.contracts.contract
108
import kotlin.coroutines.*
11-
import kotlin.jvm.JvmMultifileClass
12-
import kotlin.jvm.JvmName
139

1410
/**
1511
* Runs a new coroutine and **blocks** the current thread until its completion.

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

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ package kotlinx.coroutines
55

66
import kotlin.coroutines.*
77

8+
/**
9+
* The same as [runBlocking], but for consumption from Java.
10+
* From Kotlin's point of view, this function has the exact same signature as the regular [runBlocking].
11+
* This is done so that it can not be called from Kotlin, despite the fact that it is public.
12+
*
13+
* We do not expose this [runBlocking] in the documentation, because it is not supposed to be used from Kotlin.
14+
*
15+
* @suppress
16+
*/
17+
@Throws(InterruptedException::class)
18+
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
19+
@kotlin.internal.LowPriorityInOverloadResolution
20+
public fun <T> runBlocking(
21+
context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T
22+
): T = runBlocking(context, block)
23+
824
@Throws(InterruptedException::class)
925
internal actual fun <T> runBlockingImpl(
1026
newContext: CoroutineContext, eventLoop: EventLoop?, block: suspend CoroutineScope.() -> T

0 commit comments

Comments
 (0)