Skip to content

Commit b34dc86

Browse files
authored
Update to Kotlin 2.0-RC3 (#4129)
* Update to Kotlin 2.0-RC3 Apply all workarounds from k2 branch
1 parent bea7739 commit b34dc86

File tree

16 files changed

+202
-142
lines changed

16 files changed

+202
-142
lines changed

gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Kotlin
22
version=1.8.1-SNAPSHOT
33
group=org.jetbrains.kotlinx
4-
kotlin_version=1.9.21
4+
kotlin_version=2.0.0-RC3
5+
kotlin_language_version=2.0
56
# DO NOT rename this property without adapting kotlinx.train build chain:
67
atomicfu_version=0.23.2
78

integration-testing/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
kotlin_version=1.9.21
1+
kotlin_version=2.0.0-RC3
22
coroutines_version=1.8.1-SNAPSHOT
33
asm_version=9.3
44

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

+79-79
Large diffs are not rendered by default.

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ internal expect fun <E> identitySet(expectedSize: Int): MutableSet<E>
2121
internal expect annotation class BenignDataRace()
2222

2323
// Used **only** as a workaround for #3820 in StateFlow. Do not use anywhere else
24-
internal expect class WorkaroundAtomicReference<T>(value: T) {
25-
public fun get(): T
26-
public fun set(value: T)
27-
public fun getAndSet(value: T): T
28-
public fun compareAndSet(expected: T, value: T): Boolean
24+
internal expect class WorkaroundAtomicReference<V>(value: V) {
25+
public fun get(): V
26+
public fun set(value: V)
27+
public fun getAndSet(value: V): V
28+
public fun compareAndSet(expected: V, value: V): Boolean
2929
}
3030

3131
@Suppress("UNUSED_PARAMETER", "EXTENSION_SHADOWED_BY_MEMBER")

kotlinx-coroutines-core/jsAndWasmShared/src/internal/Concurrent.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ internal class NoOpLock {
1111

1212
internal actual fun <E> identitySet(expectedSize: Int): MutableSet<E> = HashSet(expectedSize)
1313

14-
internal actual class WorkaroundAtomicReference<T> actual constructor(private var value: T) {
14+
internal actual class WorkaroundAtomicReference<V> actual constructor(private var value: V) {
1515

16-
public actual fun get(): T = value
16+
public actual fun get(): V = value
1717

18-
public actual fun set(value: T) {
18+
public actual fun set(value: V) {
1919
this.value = value
2020
}
2121

22-
public actual fun getAndSet(value: T): T {
22+
public actual fun getAndSet(value: V): V {
2323
val prev = this.value
2424
this.value = value
2525
return prev
2626
}
2727

28-
public actual fun compareAndSet(expected: T, value: T): Boolean {
28+
public actual fun compareAndSet(expected: V, value: V): Boolean {
2929
if (this.value === expected) {
3030
this.value = value
3131
return true
Binary file not shown.

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ internal actual fun <E> identitySet(expectedSize: Int): MutableSet<E> = HashSet(
1414
@Suppress("ACTUAL_WITHOUT_EXPECT") // This suppress can be removed in 2.0: KT-59355
1515
internal actual typealias BenignDataRace = kotlin.concurrent.Volatile
1616

17-
internal actual class WorkaroundAtomicReference<T> actual constructor(value: T) {
17+
internal actual class WorkaroundAtomicReference<V> actual constructor(value: V) {
1818

19-
private val nativeAtomic = kotlin.concurrent.AtomicReference<T>(value)
19+
private val nativeAtomic = kotlin.concurrent.AtomicReference<V>(value)
2020

21-
public actual fun get(): T = nativeAtomic.value
21+
public actual fun get(): V= nativeAtomic.value
2222

23-
public actual fun set(value: T) {
23+
public actual fun set(value: V) {
2424
nativeAtomic.value = value
2525
}
2626

27-
public actual fun getAndSet(value: T): T = nativeAtomic.getAndSet(value)
27+
public actual fun getAndSet(value: V): V = nativeAtomic.getAndSet(value)
2828

29-
public actual fun compareAndSet(expected: T, value: T): Boolean = nativeAtomic.compareAndSet(expected, value)
29+
public actual fun compareAndSet(expected: V, value: V): Boolean = nativeAtomic.compareAndSet(expected, value)
3030
}

kotlinx-coroutines-test/api/kotlinx-coroutines-test.klib.api

+29-27
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/advanceUnt
3232
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runCurrent() // kotlinx.coroutines.test/runCurrent|[email protected](){}[0]
3333
final fun (kotlinx.coroutines/Dispatchers).kotlinx.coroutines.test/resetMain() // kotlinx.coroutines.test/resetMain|[email protected](){}[0]
3434
final fun (kotlinx.coroutines/Dispatchers).kotlinx.coroutines.test/setMain(kotlinx.coroutines/CoroutineDispatcher) // kotlinx.coroutines.test/setMain|[email protected](kotlinx.coroutines.CoroutineDispatcher){}[0]
35-
final fun kotlinx.coroutines.test/StandardTestDispatcher(kotlinx.coroutines.test/TestCoroutineScheduler? =..., kotlin/String? =...): kotlinx.coroutines.test/TestDispatcher // kotlinx.coroutines.test/StandardTestDispatcher|StandardTestDispatcher(kotlinx.coroutines.test.TestCoroutineScheduler?;kotlin.String?){}[0]
36-
final fun kotlinx.coroutines.test/TestScope(kotlin.coroutines/CoroutineContext =...): kotlinx.coroutines.test/TestScope // kotlinx.coroutines.test/TestScope|TestScope(kotlin.coroutines.CoroutineContext){}[0]
37-
final fun kotlinx.coroutines.test/UnconfinedTestDispatcher(kotlinx.coroutines.test/TestCoroutineScheduler? =..., kotlin/String? =...): kotlinx.coroutines.test/TestDispatcher // kotlinx.coroutines.test/UnconfinedTestDispatcher|UnconfinedTestDispatcher(kotlinx.coroutines.test.TestCoroutineScheduler?;kotlin.String?){}[0]
35+
final fun kotlinx.coroutines.test/StandardTestDispatcher(kotlinx.coroutines.test/TestCoroutineScheduler? = ..., kotlin/String? = ...): kotlinx.coroutines.test/TestDispatcher // kotlinx.coroutines.test/StandardTestDispatcher|StandardTestDispatcher(kotlinx.coroutines.test.TestCoroutineScheduler?;kotlin.String?){}[0]
36+
final fun kotlinx.coroutines.test/TestScope(kotlin.coroutines/CoroutineContext = ...): kotlinx.coroutines.test/TestScope // kotlinx.coroutines.test/TestScope|TestScope(kotlin.coroutines.CoroutineContext){}[0]
37+
final fun kotlinx.coroutines.test/UnconfinedTestDispatcher(kotlinx.coroutines.test/TestCoroutineScheduler? = ..., kotlin/String? = ...): kotlinx.coroutines.test/TestDispatcher // kotlinx.coroutines.test/UnconfinedTestDispatcher|UnconfinedTestDispatcher(kotlinx.coroutines.test.TestCoroutineScheduler?;kotlin.String?){}[0]
3838
final val kotlinx.coroutines.test/currentTime // kotlinx.coroutines.test/currentTime|@kotlinx.coroutines.test.TestScope{}currentTime[0]
3939
final fun (kotlinx.coroutines.test/TestScope).<get-currentTime>(): kotlin/Long // kotlinx.coroutines.test/currentTime.<get-currentTime>|<get-currentTime>@kotlinx.coroutines.test.TestScope(){}[0]
4040
final val kotlinx.coroutines.test/testTimeSource // kotlinx.coroutines.test/testTimeSource|@kotlinx.coroutines.test.TestScope{}testTimeSource[0]
4141
final fun (kotlinx.coroutines.test/TestScope).<get-testTimeSource>(): kotlin.time/TimeSource.WithComparableMarks // kotlinx.coroutines.test/testTimeSource.<get-testTimeSource>|<get-testTimeSource>@kotlinx.coroutines.test.TestScope(){}[0]
42-
final var kotlinx.coroutines.test/catchNonTestRelatedExceptions // kotlinx.coroutines.test/catchNonTestRelatedExceptions|<get-catchNonTestRelatedExceptions>(){}[0]
42+
final var kotlinx.coroutines.test/catchNonTestRelatedExceptions // kotlinx.coroutines.test/catchNonTestRelatedExceptions|{}catchNonTestRelatedExceptions[0]
4343
final fun <get-catchNonTestRelatedExceptions>(): kotlin/Boolean // kotlinx.coroutines.test/catchNonTestRelatedExceptions.<get-catchNonTestRelatedExceptions>|<get-catchNonTestRelatedExceptions>(){}[0]
4444
final fun <set-catchNonTestRelatedExceptions>(kotlin/Boolean) // kotlinx.coroutines.test/catchNonTestRelatedExceptions.<set-catchNonTestRelatedExceptions>|<set-catchNonTestRelatedExceptions>(kotlin.Boolean){}[0]
4545
sealed interface kotlinx.coroutines.test/TestScope : kotlinx.coroutines/CoroutineScope { // kotlinx.coroutines.test/TestScope|null[0]
@@ -49,32 +49,34 @@ sealed interface kotlinx.coroutines.test/TestScope : kotlinx.coroutines/Coroutin
4949
abstract fun <get-testScheduler>(): kotlinx.coroutines.test/TestCoroutineScheduler // kotlinx.coroutines.test/TestScope.testScheduler.<get-testScheduler>|<get-testScheduler>(){}[0]
5050
}
5151
// Targets: [native]
52-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin.time/Duration =..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|[email protected](kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
52+
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin.time/Duration = ..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|[email protected](kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
5353
// Targets: [native]
5454
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
5555
// Targets: [native]
5656
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTestLegacy(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>, kotlin/Int, kotlin/Any?) // kotlinx.coroutines.test/runTestLegacy|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>;kotlin.Int;kotlin.Any?){}[0]
5757
// Targets: [native]
58-
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext =..., kotlin.time/Duration =..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
58+
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = ..., kotlin.time/Duration = ..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
5959
// Targets: [native]
60-
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext =..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
61-
// Targets: [js]
62-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin.time/Duration =..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin/Unit> // kotlinx.coroutines.test/runTest|[email protected](kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
63-
// Targets: [js]
64-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin/Unit> // kotlinx.coroutines.test/runTest|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
65-
// Targets: [js]
66-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTestLegacy(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>, kotlin/Int, kotlin/Any?): kotlin.js/Promise<kotlin/Unit> // kotlinx.coroutines.test/runTestLegacy|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>;kotlin.Int;kotlin.Any?){}[0]
67-
// Targets: [js]
68-
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext =..., kotlin.time/Duration =..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin/Unit> // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
69-
// Targets: [js]
70-
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext =..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin/Unit> // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
71-
// Targets: [wasmJs]
72-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin.time/Duration =..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin.js/JsAny?> // kotlinx.coroutines.test/runTest|[email protected](kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
73-
// Targets: [wasmJs]
74-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin.js/JsAny?> // kotlinx.coroutines.test/runTest|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
75-
// Targets: [wasmJs]
76-
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTestLegacy(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>, kotlin/Int, kotlin/Any?): kotlin.js/Promise<kotlin.js/JsAny?> // kotlinx.coroutines.test/runTestLegacy|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>;kotlin.Int;kotlin.Any?){}[0]
77-
// Targets: [wasmJs]
78-
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext =..., kotlin.time/Duration =..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin.js/JsAny?> // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
79-
// Targets: [wasmJs]
80-
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext =..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlin.js/Promise<kotlin.js/JsAny?> // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
60+
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = ..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>) // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
61+
// Targets: [js, wasmJs]
62+
final class kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting { // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting|null[0]
63+
constructor <init>() // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.<init>|<init>(){}[0]
64+
// Targets: [js]
65+
final fun then(kotlin/Function1<kotlin/Unit, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.Unit,kotlin.Unit>){}[0]
66+
// Targets: [js]
67+
final fun then(kotlin/Function1<kotlin/Unit, kotlin/Unit>, kotlin/Function1<kotlin/Throwable, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.Unit,kotlin.Unit>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>){}[0]
68+
// Targets: [wasmJs]
69+
final fun then(kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>){}[0]
70+
// Targets: [wasmJs]
71+
final fun then(kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>, kotlin/Function1<kotlin.js/JsAny, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting.then|then(kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>;kotlin.Function1<kotlin.js.JsAny,kotlin.Unit>){}[0]
72+
}
73+
// Targets: [js, wasmJs]
74+
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin.time/Duration = ..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTest|[email protected](kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
75+
// Targets: [js, wasmJs]
76+
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTest(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTest|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
77+
// Targets: [js, wasmJs]
78+
final fun (kotlinx.coroutines.test/TestScope).kotlinx.coroutines.test/runTestLegacy(kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>, kotlin/Int, kotlin/Any?): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTestLegacy|[email protected](kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>;kotlin.Int;kotlin.Any?){}[0]
79+
// Targets: [js, wasmJs]
80+
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = ..., kotlin.time/Duration = ..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.time.Duration;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
81+
// Targets: [js, wasmJs]
82+
final fun kotlinx.coroutines.test/runTest(kotlin.coroutines/CoroutineContext = ..., kotlin/Long, kotlin.coroutines/SuspendFunction1<kotlinx.coroutines.test/TestScope, kotlin/Unit>): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // kotlinx.coroutines.test/runTest|runTest(kotlin.coroutines.CoroutineContext;kotlin.Long;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.test.TestScope,kotlin.Unit>){}[0]
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package kotlinx.coroutines.test
2+
23
import kotlinx.coroutines.*
3-
import kotlin.js.*
4+
import kotlinx.coroutines.test.internal.*
45

5-
@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE")
6-
public actual typealias TestResult = Promise<Unit>
6+
public actual typealias TestResult = JsPromiseInterfaceForTesting
77

8-
internal actual fun systemPropertyImpl(name: String): String? = null
98

9+
@Suppress("CAST_NEVER_SUCCEEDS")
1010
internal actual fun createTestResult(testProcedure: suspend CoroutineScope.() -> Unit): TestResult =
1111
GlobalScope.promise {
1212
testProcedure()
13-
}
13+
} as JsPromiseInterfaceForTesting
1414

1515
internal actual fun dumpCoroutines() { }
16+
17+
internal actual fun systemPropertyImpl(name: String): String? = null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package kotlinx.coroutines.test.internal
2+
3+
/* This is a declaration of JS's `Promise<Unit>`. We need to keep it a separate class, because
4+
`actual typealias TestResult = Promise<Unit>` fails: you can't instantiate an `expect class` with a typealias to
5+
a parametric class. So, we make a non-parametric class just for this. */
6+
/**
7+
* @suppress
8+
*/
9+
@JsName("Promise")
10+
public external class JsPromiseInterfaceForTesting {
11+
/**
12+
* @suppress
13+
*/
14+
public fun then(onFulfilled: ((Unit) -> Unit), onRejected: ((Throwable) -> Unit)): JsPromiseInterfaceForTesting
15+
/**
16+
* @suppress
17+
*/
18+
public fun then(onFulfilled: ((Unit) -> Unit)): JsPromiseInterfaceForTesting
19+
}

0 commit comments

Comments
 (0)