diff options
author | Dmitry Khalanskiy <Dmitry.Khalanskiy@jetbrains.com> | 2024-01-04 09:18:55 +0100 |
---|---|---|
committer | Dmitry Khalanskiy <Dmitry.Khalanskiy@jetbrains.com> | 2024-01-30 10:22:26 +0100 |
commit | 08491dc9ac75d148c336a62aaf49ff90aec7b34f (patch) | |
tree | 12051b1872d62a2d80bb3b0f9504926dc8138321 | |
parent | 2bf151952591a12b6d6de304a658ec38e34988c4 (diff) | |
download | kotlinx.coroutines-08491dc9ac75d148c336a62aaf49ff90aec7b34f.tar.gz |
Perform a major cleanup of Gradle scripts after the translation
* Remove the workarounds for IDEA import from gradle.kts
Without the workarounds, everything still seems to be working
fine, even after invalidating the caches.
* Clarify the opt-ins.
Unify the handling of all opt-ins in the project, and also
add opt-ins for Native that would be widespread otherwise.
Unfortunately, even after that, the IDE still complains about
not having the right opt-in in
kotlinx-coroutines-test/common/test/Helpers.kt.
* Extract the logic of grouping several source sets into a
single shared one.
* Update the kotlinx-coroutines-core build script:
- Utilize the multiplatform hierarchy to avoid defining
extra source sets.
- Reorder the code for readability.
* Fix the IDE failing to find `actual` implementations for jvmCore
by making sure `jvmCoreMain` is only defined when the IDE is not
active. Without a dependency from jvmCoreMain to jvmMain,
`expect` declarations in the IDE complained that they couldn't
find `actual` in the `jvmCore` source-set. For example, this
could be seen in
kotlinx-coroutines-core/common/src/internal/Concurrent.common.kt.
* Fix passing the stressTest system property to tests
Broken in #3966
* kotlinOptions -> compilerOptions
14 files changed, 109 insertions, 198 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index f91c4e65..3def4337 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,6 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion import org.jetbrains.kotlin.gradle.dsl.* import org.gradle.kotlin.dsl.* -import org.jetbrains.kotlin.konan.target.HostManager buildscript { if (shouldUseLocalMaven(rootProject)) { @@ -40,8 +39,6 @@ buildscript { apply(plugin = "configure-compilation-conventions") allprojects { - // the only place where HostManager could be instantiated - project.ext["hostManager"] = HostManager() val deployVersion = properties["DeployVersion"] if (deployVersion != null) version = deployVersion diff --git a/buildSrc/src/main/kotlin/OptInPreset.kt b/buildSrc/src/main/kotlin/OptInPreset.kt deleted file mode 100644 index cb111a87..00000000 --- a/buildSrc/src/main/kotlin/OptInPreset.kt +++ /dev/null @@ -1,11 +0,0 @@ -@file:JvmName("OptInPreset") - -val optInAnnotations = listOf( - "kotlin.RequiresOptIn", - "kotlin.experimental.ExperimentalTypeInference", - "kotlin.ExperimentalMultiplatform", - "kotlinx.coroutines.DelicateCoroutinesApi", - "kotlinx.coroutines.ExperimentalCoroutinesApi", - "kotlinx.coroutines.ObsoleteCoroutinesApi", - "kotlinx.coroutines.InternalCoroutinesApi", - "kotlinx.coroutines.FlowPreview") diff --git a/buildSrc/src/main/kotlin/SourceSets.kt b/buildSrc/src/main/kotlin/SourceSets.kt index 6fae1aac..340fd65c 100644 --- a/buildSrc/src/main/kotlin/SourceSets.kt +++ b/buildSrc/src/main/kotlin/SourceSets.kt @@ -1,4 +1,6 @@ +import org.gradle.api.* import org.jetbrains.kotlin.gradle.plugin.* +import org.gradle.kotlin.dsl.* fun KotlinSourceSet.configureDirectoryPaths() { if (project.isMultiplatform) { @@ -25,3 +27,30 @@ fun KotlinSourceSet.configureDirectoryPaths() { throw IllegalArgumentException("Unclear how to configure source sets for ${project.name}") } } + +/** + * Creates shared source sets for a group of source sets. + * + * [reverseDependencies] is a list of prefixes of names of source sets that depend on the new source set. + * [dependencies] is a list of prefixes of names of source sets that the new source set depends on. + * [groupName] is the prefix of the names of the new source sets. + * + * The suffixes of the source sets are "Main" and "Test". + */ +fun NamedDomainObjectContainer<KotlinSourceSet>.groupSourceSets( + groupName: String, + reverseDependencies: List<String>, + dependencies: List<String> +) { + val sourceSetSuffixes = listOf("Main", "Test") + for (suffix in sourceSetSuffixes) { + register(groupName + suffix) { + for (dep in dependencies) { + dependsOn(get(dep + suffix)) + } + for (revDep in reverseDependencies) { + get(revDep + suffix).dependsOn(this) + } + } + } +} diff --git a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts index 2cffaa00..f9427527 100644 --- a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts @@ -23,22 +23,33 @@ configure(subprojects) { allWarningsAsErrors = true freeCompilerArgs.add("-Xexplicit-api=strict") } - - /* - * Coroutines do not interop with Java and these flags provide a significant - * (i.e. close to double-digit) reduction in both bytecode and optimized dex size - */ - val bytecodeSizeReductionOptions = - if (this@configureEach is KotlinJvmCompile) listOf( + /* Coroutines do not interop with Java and these flags provide a significant + * (i.e. close to double-digit) reduction in both bytecode and optimized dex size */ + if (this@configureEach is KotlinJvmCompile) { + freeCompilerArgs.addAll( "-Xno-param-assertions", "-Xno-call-assertions", "-Xno-receiver-assertions" - ) else emptyList() - - val newOptions = listOf( - "-progressive", "-Xexpect-actual-classes" - ) + bytecodeSizeReductionOptions + optInAnnotations.map { "-opt-in=$it" } - freeCompilerArgs.addAll(newOptions) + ) + } + if (this@configureEach is KotlinNativeCompile) { + optIn.addAll( + "kotlinx.cinterop.ExperimentalForeignApi", + "kotlinx.cinterop.UnsafeNumber", + "kotlin.experimental.ExperimentalNativeApi", + ) + } + freeCompilerArgs.addAll("-progressive", "-Xexpect-actual-classes") + optIn.addAll( + "kotlin.experimental.ExperimentalTypeInference", + "kotlin.ExperimentalMultiplatform", + // our own opt-ins that we don't want to bother with in our own code: + "kotlinx.coroutines.DelicateCoroutinesApi", + "kotlinx.coroutines.ExperimentalCoroutinesApi", + "kotlinx.coroutines.ObsoleteCoroutinesApi", + "kotlinx.coroutines.InternalCoroutinesApi", + "kotlinx.coroutines.FlowPreview" + ) } } diff --git a/buildSrc/src/main/kotlin/kotlin-multiplatform-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-multiplatform-conventions.gradle.kts index e222303c..fd2d3fdb 100644 --- a/buildSrc/src/main/kotlin/kotlin-multiplatform-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-multiplatform-conventions.gradle.kts @@ -88,30 +88,20 @@ kotlin { // workaround for #3968 until this is fixed on atomicfu's side api("org.jetbrains.kotlinx:atomicfu:0.23.1") } - val jsAndWasmSharedMain by registering { - dependsOn(commonMain.get()) - } - val jsAndWasmSharedTest by registering { - dependsOn(commonTest.get()) - } - jsMain { - dependsOn(jsAndWasmSharedMain.get()) - } + jsMain { } jsTest { - dependsOn(jsAndWasmSharedTest.get()) dependencies { api("org.jetbrains.kotlin:kotlin-test-js:${version("kotlin")}") } } val wasmJsMain by getting { - dependsOn(jsAndWasmSharedMain.get()) } val wasmJsTest by getting { - dependsOn(jsAndWasmSharedTest.get()) dependencies { api("org.jetbrains.kotlin:kotlin-test-wasm-js:${version("kotlin")}") } } + groupSourceSets("jsAndWasmShared", listOf("js", "wasmJs"), listOf("common")) } } @@ -127,9 +117,5 @@ tasks.named("jvmTest", Test::class) { showStandardStreams = true events = setOf(TestLogEvent.PASSED, TestLogEvent.FAILED) } - - val stressTest = project.properties["stressTest"] - if (stressTest != null) { - systemProperty("stressTest", "stressTest") - } + project.properties["stressTest"]?.let { systemProperty("stressTest", it) } } diff --git a/kotlinx-coroutines-core/build.gradle.kts b/kotlinx-coroutines-core/build.gradle.kts index cf41626c..fed279d1 100644 --- a/kotlinx-coroutines-core/build.gradle.kts +++ b/kotlinx-coroutines-core/build.gradle.kts @@ -1,13 +1,9 @@ import org.gradle.api.tasks.testing.* import org.gradle.kotlin.dsl.* -import org.jetbrains.kotlin.gradle.dsl.* -import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.plugin.mpp.* import org.jetbrains.kotlin.gradle.targets.native.tasks.* -import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile +import org.jetbrains.kotlin.gradle.tasks.* import org.jetbrains.kotlin.gradle.testing.* -import org.jetbrains.kotlin.konan.target.* -import java.io.* plugins { kotlin("multiplatform") @@ -51,7 +47,7 @@ The overall structure is just a hack to support the scenario we are interested i For that, we have following compilations: * jvmMain compilation: [jvmCoreMain, jdk8Main] -* jvmCore compilation: [commonMain] +* jvmCore compilation: [commonMain] * jdk8 compilation: [commonMain, jvmCoreMain] Theoretically, "jvmCore" could've been "jvmMain", it is not for technical reasons, @@ -65,52 +61,38 @@ However, when creating a new compilation, we have to take care of creating a def """ ========================================================================== */ -val sourceSetSuffixes = listOf("Main", "Test") - -fun defineSourceSet(newName: String, dependsOn: List<String>, includedInPred: (String) -> Boolean) { - for (suffix in sourceSetSuffixes) { - val newSS = kotlin.sourceSets.maybeCreate(newName + suffix) - for (dep in dependsOn) { - newSS.dependsOn(kotlin.sourceSets[dep + suffix]) +kotlin { + sourceSets { + // using the source set names from <https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template> + groupSourceSets("concurrent", listOf("jvm", "native"), listOf("common")) + if (project.nativeTargetsAreEnabled) { + // TODO: 'nativeDarwin' behaves exactly like 'apple', we can remove it + groupSourceSets("nativeDarwin", listOf("apple"), listOf("native")) + groupSourceSets("nativeOther", listOf("linux", "mingw", "androidNative"), listOf("native")) + } + jvmMain { + dependencies { + compileOnly("com.google.android:annotations:4.1.1.4") + } } - for (curSS in kotlin.sourceSets) { - val curName = curSS.name - if (curName.endsWith(suffix)) { - val prefix = curName.substring(0, curName.length - suffix.length) - if (includedInPred(prefix)) curSS.dependsOn(newSS) + jvmTest { + dependencies { + api("org.jetbrains.kotlinx:lincheck:${version("lincheck")}") + api("org.jetbrains.kotlinx:kotlinx-knit-test:${version("knit")}") + implementation(project(":android-unit-tests")) + implementation("org.openjdk.jol:jol-core:0.16") } } } -} - -fun isNativeDarwin(name: String): Boolean { return listOf("ios", "macos", "tvos", "watchos").any { name.startsWith(it) } } - -fun isNativeOther(name: String): Boolean { return listOf("linux", "mingw", "androidNative").any { name.startsWith(it) } } - -defineSourceSet("concurrent", listOf("common")) { it in listOf("jvm", "native") } - -if (project.nativeTargetsAreEnabled) { - defineSourceSet("nativeDarwin", listOf("native")) { isNativeDarwin(it) } - defineSourceSet("nativeOther", listOf("native")) { isNativeOther(it) } -} - -/* ========================================================================== */ - - -/* - * All platform plugins and configuration magic happens here instead of build.gradle - * because JMV-only projects depend on core, thus core should always be initialized before configuration. - */ -kotlin { /* - * Configure two test runs: + * Configure two test runs for Native: * 1) Main thread * 2) BG thread (required for Dispatchers.Main tests on Darwin) * * All new MM targets are build with optimize = true to have stress tests properly run. */ targets.withType(KotlinNativeTargetWithTests::class).configureEach { - binaries.getTest("DEBUG").apply { + binaries.getTest(DEBUG).apply { optimized = true } @@ -129,14 +111,9 @@ kotlin { } } - val jvmMain = sourceSets.jvmMain - val jvmCoreMain = sourceSets.create("jvmCoreMain") - val jdk8Main = sourceSets.create("jdk8Main") - jdk8Main.dependsOn(jvmMain.get()) - /** * See: https://youtrack.jetbrains.com/issue/KTIJ-25959 - * The dependency from jvmCore to jvmMain is only for CLI builds and not intended for the IDE. + * The introduction of jvmCore is only for CLI builds and not intended for the IDE. * In the current setup there are two tooling unfriendly configurations used: * 1: - jvmMain, despite being a platform source set, is not a leaf (jvmCoreMain and jdk8Main dependOn it) * 2: - jvmMain effectively becomes a 'shared jvm' source set @@ -144,19 +121,23 @@ kotlin { * Using this kludge here, will prevent issue 2 from being visible to the IDE. * Therefore jvmMain will resolve using the 'single' compilation it participates in (from the perspective of the IDE) */ - if (!Idea.active) { - jvmCoreMain.dependsOn(jvmMain.get()) + val jvmCoreMain = if (Idea.active) null else sourceSets.create("jvmCoreMain") { + dependsOn(sourceSets.jvmMain.get()) + } + val jdk8Main = sourceSets.create("jdk8Main") { + dependsOn(sourceSets.jvmMain.get()) } jvm { - val main = compilations.getByName("main") - main.source(jvmCoreMain) - main.source(jdk8Main) + compilations.named("main") { + jvmCoreMain?.let { source(it) } + source(jdk8Main) + } /* Create compilation for jvmCore to prove that jvmMain does not rely on jdk8 */ compilations.create("CoreMain") { /* jvmCore is automatically matched as 'defaultSourceSet' for the compilation, due to its name */ - tasks.getByName("check").dependsOn(compileKotlinTaskProvider) + tasks.getByName("check").dependsOn(compileTaskProvider) } // For animal sniffer @@ -171,82 +152,11 @@ benchmark { } } -fun configureKotlinJvmPlatform(configuration: Configuration) { - configuration.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm) -} - -// todo:KLUDGE: This is needed to workaround dependency resolution between Java and MPP modules -configurations { - configureKotlinJvmPlatform(kotlinCompilerPluginClasspath.get()) -} - // Update module name for metadata artifact to avoid conflicts // see https://github.com/Kotlin/kotlinx.coroutines/issues/1797 -val compileKotlinMetadata by tasks.getting(KotlinCompile::class) { - kotlinOptions { - freeCompilerArgs = freeCompilerArgs + listOf("-module-name", "kotlinx-coroutines-core-common") - } -} - -// :KLUDGE: Idea.active: This is needed to workaround resolve problems after importing this project to IDEA -fun configureNativeSourceSetPreset(name: String, preset: KotlinNativeTargetWithHostTestsPreset) { - val hostMainCompilation = project.kotlin.targetFromPreset(preset).compilations.getByName("main") - // Look for platform libraries in "implementation" for default source set - val implementationConfiguration = configurations[hostMainCompilation.defaultSourceSet.implementationMetadataConfigurationName] - // Now find the libraries: Finds platform libs & stdlib, but platform declarations are still not resolved due to IDE bugs - val hostNativePlatformLibs = files( - provider { - implementationConfiguration.filter { - it.path.endsWith(".klib") || it.absolutePath.contains("klib${File.separator}platform") || it.absolutePath.contains("stdlib") - } - } - ) - // Add all those dependencies - for (suffix in sourceSetSuffixes) { - kotlin.sourceSets.getByName(name + suffix) { - dependencies.add(implementationMetadataConfigurationName, hostNativePlatformLibs) - } - } -} - -// :KLUDGE: Idea.active: Configure platform libraries for native source sets when working in IDEA -if (Idea.active && project.nativeTargetsAreEnabled) { - val manager = project.ext["hostManager"] as HostManager - val linuxPreset = kotlin.presets.getByName("linuxX64", KotlinNativeTargetWithHostTestsPreset::class) - val macosPreset = kotlin.presets.getByName("macosX64", KotlinNativeTargetWithHostTestsPreset::class) - // linux should be always available (cross-compilation capable) -- use it as default - assert(manager.isEnabled(linuxPreset.konanTarget)) - // use macOS libs for nativeDarwin if available - val macosAvailable = manager.isEnabled(macosPreset.konanTarget) - // configure source sets - configureNativeSourceSetPreset("native", linuxPreset) - configureNativeSourceSetPreset("nativeOther", linuxPreset) - configureNativeSourceSetPreset("nativeDarwin", if (macosAvailable) macosPreset else linuxPreset) -} - -kotlin.sourceSets { - val jvmMain by getting { - dependencies { - compileOnly("com.google.android:annotations:4.1.1.4") - } - } - - val jvmTest by getting { - dependencies { - api("org.jetbrains.kotlinx:lincheck:${version("lincheck")}") - api("org.jetbrains.kotlinx:kotlinx-knit-test:${version("knit")}") - implementation(project(":android-unit-tests")) - implementation("org.openjdk.jol:jol-core:0.16") - } - } -} - -kotlin.sourceSets.configureEach { - // Do not apply 'ExperimentalForeignApi' where we have allWarningsAsErrors set - if (name in listOf("jvmMain", "jvmCoreMain", "jsMain", "wasmJsMain", "jsAndWasmSharedMain", "concurrentMain", "commonMain")) return@configureEach - languageSettings { - optIn("kotlinx.cinterop.ExperimentalForeignApi") - optIn("kotlin.experimental.ExperimentalNativeApi") +val compileKotlinMetadata by tasks.getting(KotlinCompilationTask::class) { + compilerOptions { + freeCompilerArgs.addAll("-module-name", "kotlinx-coroutines-core-common") } } @@ -268,7 +178,7 @@ val jvmTest by tasks.getting(Test::class) { } if (Idea.active) { // Configure the IDEA runner for Lincheck - configureJvmForLincheck(this) + configureJvmForLincheck() } } @@ -305,12 +215,12 @@ val jvmStressTest by tasks.registering(Test::class) { include("**/*StressTest.*") enableAssertions = true testLogging.showStandardStreams = true - systemProperty("kotlinx.coroutines.scheduler.keep.alive.sec", "100000") // any unpark problem hangs test + systemProperty("kotlinx.coroutines.scheduler.keep.alive.sec", 100000) // any unpark problem hangs test // Adjust internal algorithmic parameters to increase the testing quality instead of performance. - systemProperty("kotlinx.coroutines.semaphore.segmentSize", "1") - systemProperty("kotlinx.coroutines.semaphore.maxSpinCycles", "10") - systemProperty("kotlinx.coroutines.bufferedChannel.segmentSize", "2") - systemProperty("kotlinx.coroutines.bufferedChannel.expandBufferCompletionWaitIterations", "1") + systemProperty("kotlinx.coroutines.semaphore.segmentSize", 1) + systemProperty("kotlinx.coroutines.semaphore.maxSpinCycles", 10) + systemProperty("kotlinx.coroutines.bufferedChannel.segmentSize", 2) + systemProperty("kotlinx.coroutines.bufferedChannel.expandBufferCompletionWaitIterations", 1) } val jvmLincheckTest by tasks.registering(Test::class) { @@ -320,7 +230,7 @@ val jvmLincheckTest by tasks.registering(Test::class) { include("**/*LincheckTest*") enableAssertions = true testLogging.showStandardStreams = true - configureJvmForLincheck(this) + configureJvmForLincheck() } // Additional Lincheck tests with `segmentSize = 2`. @@ -335,22 +245,21 @@ val jvmLincheckTestAdditional by tasks.registering(Test::class) { include("**/Semaphore*LincheckTest*") enableAssertions = true testLogging.showStandardStreams = true - configureJvmForLincheck(this, true) + configureJvmForLincheck(segmentSize = 2) } -fun configureJvmForLincheck(task: Test, additional: Boolean = false) { - task.minHeapSize = "1g" - task.maxHeapSize = "4g" // we may need more space for building an interleaving tree in the model checking mode +fun Test.configureJvmForLincheck(segmentSize: Int = 1) { + minHeapSize = "1g" + maxHeapSize = "4g" // we may need more space for building an interleaving tree in the model checking mode // https://github.com/JetBrains/lincheck#java-9 - task.jvmArgs = listOf("--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", // required for transformation + jvmArgs = listOf("--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", // required for transformation "--add-exports", "java.base/sun.security.action=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.util=ALL-UNNAMED") // in the model checking mode // Adjust internal algorithmic parameters to increase the testing quality instead of performance. - val segmentSize = if (additional) "2" else "1" - task.systemProperty("kotlinx.coroutines.semaphore.segmentSize", segmentSize) - task.systemProperty("kotlinx.coroutines.semaphore.maxSpinCycles", "1") // better for the model checking mode - task.systemProperty("kotlinx.coroutines.bufferedChannel.segmentSize", segmentSize) - task.systemProperty("kotlinx.coroutines.bufferedChannel.expandBufferCompletionWaitIterations", "1") + systemProperty("kotlinx.coroutines.semaphore.segmentSize", segmentSize) + systemProperty("kotlinx.coroutines.semaphore.maxSpinCycles", 1) // better for the model checking mode + systemProperty("kotlinx.coroutines.bufferedChannel.segmentSize", segmentSize) + systemProperty("kotlinx.coroutines.bufferedChannel.expandBufferCompletionWaitIterations", 1) } // Always check additional test sets diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt b/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt index a9e8e616..cad34a0d 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Delay.kt @@ -107,7 +107,6 @@ public fun <T> Flow<T>.debounce(timeoutMillis: Long): Flow<T> { * @param timeoutMillis [T] is the emitted value and the return value is timeout in milliseconds. */ @FlowPreview -@OptIn(kotlin.experimental.ExperimentalTypeInference::class) @OverloadResolutionByLambdaReturnType public fun <T> Flow<T>.debounce(timeoutMillis: (T) -> Long): Flow<T> = debounceInternal(timeoutMillis) @@ -192,7 +191,6 @@ public fun <T> Flow<T>.debounce(timeout: Duration): Flow<T> = */ @FlowPreview @JvmName("debounceDuration") -@OptIn(kotlin.experimental.ExperimentalTypeInference::class) @OverloadResolutionByLambdaReturnType public fun <T> Flow<T>.debounce(timeout: (T) -> Duration): Flow<T> = debounceInternal { emittedItem -> diff --git a/kotlinx-coroutines-core/common/src/internal/Concurrent.common.kt b/kotlinx-coroutines-core/common/src/internal/Concurrent.common.kt index 1113be6f..8aa3df41 100644 --- a/kotlinx-coroutines-core/common/src/internal/Concurrent.common.kt +++ b/kotlinx-coroutines-core/common/src/internal/Concurrent.common.kt @@ -18,5 +18,4 @@ internal expect fun <E> identitySet(expectedSize: Int): MutableSet<E> */ @OptionalExpectation @Target(AnnotationTarget.FIELD) -@OptIn(ExperimentalMultiplatform::class) internal expect annotation class BenignDataRace() diff --git a/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt b/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt index 4b04185f..34052936 100644 --- a/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt +++ b/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt @@ -91,7 +91,6 @@ class ConsumeTest: TestBase() { } /** Check that [BroadcastChannel.consume] does not suffer from KT-58685 */ - @OptIn(ObsoleteCoroutinesApi::class) @Suppress("DEPRECATION", "DEPRECATION_ERROR") @Test fun testBroadcastChannelConsumeJsMiscompilation() = runTest { diff --git a/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt b/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt index 46acaeb8..fce21b20 100644 --- a/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt +++ b/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt @@ -8,7 +8,6 @@ import org.junit.* * Tests that shared flows keep strong reference to their source flows. * See https://github.com/Kotlin/kotlinx.coroutines/issues/2557 */ -@OptIn(DelicateCoroutinesApi::class) class SharingReferenceTest : TestBase() { private val token = object {} diff --git a/kotlinx-coroutines-core/native/src/Builders.kt b/kotlinx-coroutines-core/native/src/Builders.kt index a49ba6c5..d10cb48a 100644 --- a/kotlinx-coroutines-core/native/src/Builders.kt +++ b/kotlinx-coroutines-core/native/src/Builders.kt @@ -2,7 +2,6 @@ package kotlinx.coroutines import kotlinx.cinterop.* -import platform.posix.* import kotlin.contracts.* import kotlin.coroutines.* import kotlin.native.concurrent.* diff --git a/kotlinx-coroutines-core/native/src/internal/Concurrent.kt b/kotlinx-coroutines-core/native/src/internal/Concurrent.kt index 8df5c52a..eb9c8a59 100644 --- a/kotlinx-coroutines-core/native/src/internal/Concurrent.kt +++ b/kotlinx-coroutines-core/native/src/internal/Concurrent.kt @@ -7,7 +7,6 @@ import kotlinx.atomicfu.locks.withLock as withLock2 @Suppress("ACTUAL_WITHOUT_EXPECT") internal actual typealias ReentrantLock = kotlinx.atomicfu.locks.SynchronizedObject -@OptIn(UnsafeNumber::class) internal actual inline fun <T> ReentrantLock.withLock(action: () -> T): T = this.withLock2(action) internal actual fun <E> identitySet(expectedSize: Int): MutableSet<E> = HashSet() diff --git a/kotlinx-coroutines-core/native/src/internal/Synchronized.kt b/kotlinx-coroutines-core/native/src/internal/Synchronized.kt index 3a4b0cf8..43ff8bd9 100644 --- a/kotlinx-coroutines-core/native/src/internal/Synchronized.kt +++ b/kotlinx-coroutines-core/native/src/internal/Synchronized.kt @@ -13,6 +13,5 @@ public actual typealias SynchronizedObject = kotlinx.atomicfu.locks.Synchronized /** * @suppress **This an internal API and should not be used from general code.** */ -@OptIn(UnsafeNumber::class) @InternalCoroutinesApi public actual inline fun <T> synchronizedImpl(lock: SynchronizedObject, block: () -> T): T = lock.withLock2(block) diff --git a/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt b/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt index 31e41731..786f0f21 100644 --- a/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt +++ b/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt @@ -16,7 +16,6 @@ internal actual fun createMainDispatcher(default: CoroutineDispatcher): MainCoro internal actual fun createDefaultDispatcher(): CoroutineDispatcher = DarwinGlobalQueueDispatcher private object DarwinGlobalQueueDispatcher : CoroutineDispatcher() { - @OptIn(UnsafeNumber::class) override fun dispatch(context: CoroutineContext, block: Runnable) { autoreleasepool { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.convert(), 0u)) { @@ -75,7 +74,6 @@ private val TIMER_DISPOSED = NativePtr.NULL.plus(1) private class Timer : DisposableHandle { private val ref = AtomicNativePtr(TIMER_NEW) - @OptIn(UnsafeNumber::class) fun start(timeMillis: Long, timerBlock: TimerBlock) { val fireDate = CFAbsoluteTimeGetCurrent() + timeMillis / 1000.0 val timer = CFRunLoopTimerCreateWithHandler(null, fireDate, 0.0, 0u, 0, timerBlock) |