Skip to content

Commit 44b108d

Browse files
authored
Revert "chore(deps): update kotlin core dependencies to v1.9.0 (#540)" (#543)
This reverts commit 8dd2505.
1 parent 8dd2505 commit 44b108d

9 files changed

Lines changed: 675 additions & 275 deletions

File tree

buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/kotlin-library.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ kotlin {
6464
* linux mingw macos
6565
*/
6666
sourceSets {
67+
all {
68+
languageSettings.optIn("kotlin.RequiresOptIn")
69+
}
6770
val commonMain by getting
6871
val commonTest by getting {
6972
dependencies {

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[versions]
2-
kotlin = "1.9.0"
2+
kotlin = "1.8.22"
33
okio = "3.4.0"
44
serialization = "1.5.1"
55
diktat = "1.2.5"
66
kotlinx-cli = "0.3.5"
77
kotlinx-datetime = "0.4.0"
8-
kotlinx-coroutines = "1.7.2"
8+
kotlinx-coroutines = "1.6.3-native-mt"
99
junit = "5.10.0"
1010
ktoml = "0.5.0"
1111
multiplatform-diff = "0.4.0"

renovate.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"*"
1616
],
1717
"excludePackagePatterns": [
18-
"^org\\.jetbrains\\.kotlinx?[.:]",
18+
"^org\\.jetbrains\\.kotlin[.:]",
1919
"^org\\.cqfn\\.diktat[.:]diktat-gradle-plugin"
2020
],
2121
"matchUpdateTypes": [
@@ -37,10 +37,17 @@
3737
{
3838
"managers": ["gradle"],
3939
"matchPackagePatterns": [
40-
"^org\\.jetbrains\\.kotlinx?[.:]"
40+
"^org\\.jetbrains\\.kotlin[.:]"
4141
],
4242
"groupName": "Kotlin core dependencies",
4343
"groupSlug": "core-kotlin"
44+
},
45+
{
46+
"managers": ["gradle"],
47+
"matchPackagePatterns": [
48+
"^org\\.jetbrains\\.kotlinx:kotlinx-coroutines.*"
49+
],
50+
"versioning": "docker"
4451
}
4552
]
4653
}

save-common/src/commonMain/kotlin/com/saveourtool/save/core/utils/PlatformUtils.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,40 @@ enum class CurrentOs {
1515
LINUX, MACOS, UNDEFINED, WINDOWS
1616
}
1717

18+
/**
19+
* Atomic values
20+
*/
21+
expect class AtomicInt(value: Int) {
22+
/**
23+
* @return value
24+
*/
25+
fun get(): Int
26+
27+
/**
28+
* @param delta increments the value_ by delta
29+
* @return the new value
30+
*/
31+
fun addAndGet(delta: Int): Int
32+
}
33+
34+
/**
35+
* Atomic boolean
36+
*/
37+
@Suppress("FUNCTION_BOOLEAN_PREFIX")
38+
expect class AtomicBoolean(value: Boolean) {
39+
/**
40+
* @return value
41+
*/
42+
fun get(): Boolean
43+
44+
/**
45+
* @param expect expected value
46+
* @param update updated value
47+
* @return the result of the comparison
48+
*/
49+
fun compareAndSet(expect: Boolean, update: Boolean): Boolean
50+
}
51+
1852
/**
1953
* Class that holds value and shares atomic reference to the value (native only)
2054
*

save-common/src/jsMain/kotlin/com/saveourtool/save/core/utils/PlatformUtils.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ package com.saveourtool.save.core.utils
1313

1414
import com.saveourtool.save.core.config.OutputStreamType
1515

16+
actual class AtomicInt actual constructor(value: Int) {
17+
actual fun get(): Int = error("Not implemented for JS")
18+
actual fun addAndGet(delta: Int): Int = error("Not implemented for JS")
19+
}
20+
21+
actual class AtomicBoolean actual constructor(value: Boolean) {
22+
actual fun get(): Boolean = error("Not implemented for JS")
23+
actual fun compareAndSet(expect: Boolean, update: Boolean): Boolean = error("Not implemented for JS")
24+
}
25+
1626
@Suppress("USE_DATA_CLASS")
1727
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
1828
private var value: T = valueToStore

save-common/src/jvmMain/kotlin/com/saveourtool/save/core/utils/PlatformUtils.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
"MISSING_KDOC_TOP_LEVEL",
44
"MISSING_KDOC_ON_FUNCTION",
55
"FILE_NAME_MATCH_CLASS",
6-
"MatchingDeclarationName",
76
)
87

98
package com.saveourtool.save.core.utils
109

1110
import com.saveourtool.save.core.config.OutputStreamType
1211

12+
actual typealias AtomicInt = java.util.concurrent.atomic.AtomicInteger
13+
14+
actual typealias AtomicBoolean = java.util.concurrent.atomic.AtomicBoolean
15+
1316
@Suppress("USE_DATA_CLASS")
1417
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
1518
private val holder: java.util.concurrent.atomic.AtomicReference<T> = java.util.concurrent.atomic.AtomicReference(valueToStore)

save-common/src/nativeMain/kotlin/com/saveourtool/save/core/files/FileUtils.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ import com.saveourtool.save.core.logging.logTrace
99
import okio.FileSystem
1010
import okio.Path
1111
import okio.Path.Companion.toPath
12+
import platform.posix.FTW
1213
import platform.posix.FTW_DEPTH
1314
import platform.posix.nftw
1415
import platform.posix.remove
16+
import platform.posix.stat
1517

18+
import kotlinx.cinterop.ByteVar
19+
import kotlinx.cinterop.CPointer
1620
import kotlinx.cinterop.staticCFunction
1721
import kotlinx.cinterop.toKString
1822

@@ -25,8 +29,7 @@ actual val fs: FileSystem = FileSystem.SYSTEM
2529
*/
2630
@Suppress("MAGIC_NUMBER", "MagicNumber")
2731
actual fun FileSystem.myDeleteRecursively(path: Path) {
28-
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
29-
nftw(path.toString(), staticCFunction { pathName, _, _, _ ->
32+
nftw(path.toString(), staticCFunction<CPointer<ByteVar>?, CPointer<stat>?, Int, CPointer<FTW>?, Int> { pathName, _, _, _ ->
3033
val fileName = pathName!!.toKString()
3134
logTrace("Attempt to delete file $fileName")
3235
remove(fileName)

save-common/src/nativeMain/kotlin/com/saveourtool/save/core/utils/PlatformUtils.kt

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE",
33
"MISSING_KDOC_TOP_LEVEL",
44
"MISSING_KDOC_ON_FUNCTION",
5-
"FILE_NAME_MATCH_CLASS",
6-
"MatchingDeclarationName",
5+
"FILE_NAME_MATCH_CLASS"
76
)
87

98
package com.saveourtool.save.core.utils
@@ -15,11 +14,44 @@ import platform.posix.fprintf
1514
import platform.posix.stderr
1615
import platform.posix.stdout
1716

18-
import kotlinx.cinterop.ExperimentalForeignApi
17+
/**
18+
* Atomic values
19+
*/
20+
actual class AtomicInt actual constructor(value: Int) {
21+
private val holder = kotlin.native.concurrent.AtomicInt(value)
22+
23+
/**
24+
* @return value
25+
*/
26+
actual fun get(): Int = holder.value
27+
28+
/**
29+
* @param delta increments the value_ by delta
30+
* @return the new value
31+
*/
32+
actual fun addAndGet(delta: Int): Int = holder.addAndGet(delta)
33+
}
34+
35+
@Suppress("FUNCTION_BOOLEAN_PREFIX")
36+
actual class AtomicBoolean actual constructor(value: Boolean) {
37+
private val holder = kotlin.native.concurrent.AtomicReference(value)
38+
39+
/**
40+
* @return value
41+
*/
42+
actual fun get(): Boolean = holder.value
43+
44+
/**
45+
* @param expect expected value
46+
* @param update updated value
47+
* @return the result of the comparison
48+
*/
49+
actual fun compareAndSet(expect: Boolean, update: Boolean): Boolean = holder.compareAndSet(expect, update)
50+
}
1951

2052
@Suppress("USE_DATA_CLASS")
2153
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
22-
private val holder: kotlin.concurrent.AtomicReference<T> = kotlin.concurrent.AtomicReference(valueToStore)
54+
private val holder: kotlin.native.concurrent.AtomicReference<T> = kotlin.native.concurrent.AtomicReference(valueToStore)
2355
actual fun get(): T = holder.value
2456
actual fun set(newValue: T) {
2557
holder.value = newValue
@@ -72,14 +104,11 @@ actual fun writeToConsole(msg: String, outputType: OutputStreamType) {
72104
* @param msg a message string
73105
* @param output output stream (stdout or stderr)
74106
*/
75-
private fun processStandardStreams(msg: String, output: OutputStreamType) {
76-
@OptIn(ExperimentalForeignApi::class)
107+
fun processStandardStreams(msg: String, output: OutputStreamType) {
77108
val stream = when (output) {
78109
OutputStreamType.STDERR -> stderr
79110
else -> stdout
80111
}
81-
@OptIn(ExperimentalForeignApi::class)
82112
fprintf(stream, msg.escapePercent() + "\n")
83-
@OptIn(ExperimentalForeignApi::class)
84113
fflush(stream)
85114
}

0 commit comments

Comments
 (0)