Skip to content

Commit 0238282

Browse files
authored
Kotlin 1.9.20: new target hierarchy setup, opt in to 'expect'/'actual' classes (hoc081098#193)
🎉🎉🎉🎉
1 parent a599a4b commit 0238282

File tree

5 files changed

+29
-123
lines changed

5 files changed

+29
-123
lines changed

build.gradle.kts

+28-120
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
55
import org.gradle.api.tasks.testing.logging.TestLogEvent
66
import org.jetbrains.dokka.gradle.DokkaTask
77
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
8+
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
89
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests
910
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
1011
import java.net.URL
@@ -60,22 +61,18 @@ kotlin {
6061
}
6162
}
6263
browser {
63-
testTask(
64-
Action {
65-
useMocha {
66-
timeout = "10s"
67-
}
68-
},
69-
)
64+
testTask {
65+
useMocha {
66+
timeout = "10s"
67+
}
68+
}
7069
}
7170
nodejs {
72-
testTask(
73-
Action {
74-
useMocha {
75-
timeout = "10s"
76-
}
77-
},
78-
)
71+
testTask {
72+
useMocha {
73+
timeout = "10s"
74+
}
75+
}
7976
}
8077
}
8178

@@ -107,130 +104,28 @@ kotlin {
107104
androidNativeX64()
108105

109106
sourceSets {
110-
val commonMain by getting {
107+
commonMain {
111108
dependencies {
112109
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
113110
}
114111
}
115-
val commonTest by getting {
112+
commonTest {
116113
dependencies {
117114
implementation(kotlin("test-common"))
118115
implementation(kotlin("test-annotations-common"))
119116
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
120117
}
121118
}
122-
val jvmMain by getting {
123-
dependsOn(commonMain)
124-
}
125-
val jvmTest by getting {
126-
dependsOn(commonTest)
127-
119+
jvmTest {
128120
dependencies {
129121
implementation(kotlin("test-junit"))
130122
}
131123
}
132-
val jsMain by getting {
133-
dependsOn(commonMain)
134-
}
135-
val jsTest by getting {
124+
jsTest {
136125
dependencies {
137126
implementation(kotlin("test-js"))
138127
}
139128
}
140-
141-
val nativeMain by creating {
142-
dependsOn(commonMain)
143-
}
144-
val nativeTest by creating {
145-
dependsOn(commonTest)
146-
}
147-
148-
val darwinMain by creating {
149-
dependsOn(nativeMain)
150-
}
151-
val darwinTest by creating {
152-
dependsOn(nativeTest)
153-
}
154-
155-
val linuxMain by creating {
156-
dependsOn(nativeMain)
157-
}
158-
val linuxTest by creating {
159-
dependsOn(nativeTest)
160-
}
161-
162-
val pthreadAndroidMain by creating {
163-
dependsOn(nativeMain)
164-
}
165-
val pthreadAndroidTest by creating {
166-
dependsOn(nativeTest)
167-
}
168-
169-
val appleTargets =
170-
listOf(
171-
"iosX64",
172-
"iosSimulatorArm64",
173-
"iosArm64",
174-
"macosX64",
175-
"macosArm64",
176-
"tvosArm64",
177-
"tvosX64",
178-
"tvosSimulatorArm64",
179-
"watchosArm32",
180-
"watchosArm64",
181-
"watchosSimulatorArm64",
182-
"watchosX64",
183-
"watchosSimulatorArm64",
184-
"watchosDeviceArm64",
185-
)
186-
187-
val linuxTargets =
188-
listOf(
189-
"linuxX64",
190-
"linuxArm64",
191-
)
192-
193-
val androidNativeTargets =
194-
listOf(
195-
"androidNativeArm32",
196-
"androidNativeArm64",
197-
"androidNativeX86",
198-
"androidNativeX64",
199-
)
200-
201-
appleTargets.forEach {
202-
getByName("${it}Main") {
203-
dependsOn(darwinMain)
204-
}
205-
getByName("${it}Test") {
206-
dependsOn(darwinTest)
207-
}
208-
}
209-
210-
linuxTargets.forEach {
211-
getByName("${it}Main") {
212-
dependsOn(linuxMain)
213-
}
214-
getByName("${it}Test") {
215-
dependsOn(linuxTest)
216-
}
217-
}
218-
219-
androidNativeTargets.forEach {
220-
getByName("${it}Main") {
221-
dependsOn(pthreadAndroidMain)
222-
}
223-
getByName("${it}Test") {
224-
dependsOn(pthreadAndroidTest)
225-
}
226-
}
227-
228-
getByName("mingwX64Main") {
229-
dependsOn(nativeMain)
230-
}
231-
getByName("mingwX64Test") {
232-
dependsOn(nativeTest)
233-
}
234129
}
235130

236131
// enable running ios tests on a background thread as well
@@ -250,6 +145,19 @@ kotlin {
250145
}
251146
}
252147

148+
tasks.withType<KotlinCompile<*>>().configureEach {
149+
kotlinOptions {
150+
// 'expect'/'actual' classes (including interfaces, objects, annotations, enums,
151+
// and 'actual' typealiases) are in Beta.
152+
// You can use -Xexpect-actual-classes flag to suppress this warning.
153+
// Also see: https://youtrack.jetbrains.com/issue/KT-61573
154+
freeCompilerArgs +=
155+
listOf(
156+
"-Xexpect-actual-classes",
157+
)
158+
}
159+
}
160+
253161
spotless {
254162
kotlin {
255163
target("**/*.kt")

src/commonTest/kotlin/com/hoc081098/flowext/PairwiseTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import kotlinx.coroutines.flow.take
4242

4343
private data class MyTuple2<A, B>(val first: A, val second: B)
4444

45+
@Suppress("NOTHING_TO_INLINE")
4546
private inline infix fun <A, B> A.with(second: B) = MyTuple2(this, second)
4647

4748
@ExperimentalCoroutinesApi

src/commonTest/kotlin/com/hoc081098/flowext/SelectorsTest.kt

-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ package com.hoc081098.flowext
2626

2727
import com.hoc081098.flowext.utils.BaseTest
2828
import com.hoc081098.flowext.utils.test
29-
import kotlin.native.concurrent.SharedImmutable
3029
import kotlin.test.Test
3130
import kotlin.test.assertEquals
3231
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -73,10 +72,8 @@ private fun <T, R> Flow<T>.scanSkipFirst(
7372
operation: suspend (acc: R, value: T) -> R,
7473
): Flow<R> = scan(initial, operation).drop(1)
7574

76-
@SharedImmutable
7775
private val zeroToTen = List(10) { it.toString() }
7876

79-
@SharedImmutable
8077
private val reducer: (acc: State, value: Int) -> State = { state, action ->
8178
when (action) {
8279
// items

0 commit comments

Comments
 (0)