Replaced overriding kotlin stdlib classes by expect/actual with non-JVM source set
This commit is contained in:
parent
c154fc7610
commit
758bc31a85
@ -15,7 +15,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.landgrafhomyak.utility"
|
group = "ru.landgrafhomyak.utility"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -25,6 +25,8 @@ xomrk {
|
|||||||
kotlin {
|
kotlin {
|
||||||
setCompatibilityWithKotlin(KotlinVersion.KOTLIN_2_0)
|
setCompatibilityWithKotlin(KotlinVersion.KOTLIN_2_0)
|
||||||
optInContracts()
|
optInContracts()
|
||||||
|
noWarnExpectActual()
|
||||||
|
warningsAsErrors()
|
||||||
|
|
||||||
defineAllMultiplatformTargets()
|
defineAllMultiplatformTargets()
|
||||||
|
|
||||||
@ -46,24 +48,34 @@ xomrk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(kotlin("stdlib"))
|
compileOnly(kotlin("stdlib"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jvmMain {
|
val jvmMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(kotlin("stdlib"))
|
compileOnly(kotlin("stdlib"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.configureEach {
|
val nonJvmMain by creating {
|
||||||
if (name == "jvmMain") return@configureEach
|
dependsOn(commonMain)
|
||||||
if (name == "commonMain") return@configureEach
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib"))
|
implementation(kotlin("stdlib"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets.configureEach {
|
||||||
|
when {
|
||||||
|
// commonMain !in dependsOn -> return@configureEach
|
||||||
|
!name.endsWith("Main") -> return@configureEach
|
||||||
|
this@configureEach === commonMain -> return@configureEach
|
||||||
|
this@configureEach === jvmMain -> return@configureEach
|
||||||
|
this@configureEach === nonJvmMain -> return@configureEach
|
||||||
|
}
|
||||||
|
dependsOn(nonJvmMain)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
|
kotlin.mpp.applyDefaultHierarchyTemplate=false
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.landgrafhomyak.utility.highlevel_try_finally
|
||||||
|
|
||||||
|
@PublishedApi
|
||||||
|
internal expect object ExceptionsKt {
|
||||||
|
@PublishedApi
|
||||||
|
internal fun addSuppressed(e1: Throwable?, e2: Throwable?)
|
||||||
|
}
|
@ -86,7 +86,7 @@ inline fun <R> safeAutoClose3e(
|
|||||||
try {
|
try {
|
||||||
onError(e1)
|
onError(e1)
|
||||||
} catch (e2: Throwable) {
|
} catch (e2: Throwable) {
|
||||||
e1.addSuppressed(e2)
|
ExceptionsKt.addSuppressed(e1, e2)
|
||||||
}
|
}
|
||||||
throw e1
|
throw e1
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package kotlin
|
|
||||||
|
|
||||||
import java.util.Objects
|
|
||||||
|
|
||||||
@PublishedApi
|
|
||||||
internal object ExceptionsKt {
|
|
||||||
@Suppress("RemoveRedundantQualifierName")
|
|
||||||
@JvmStatic
|
|
||||||
@PublishedApi
|
|
||||||
internal fun addSuppressed(`this`: kotlin.Throwable, e2: kotlin.Throwable?) {
|
|
||||||
(java.lang.Throwable::addSuppressed)(`this` as java.lang.Throwable, e2)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package kotlin.jvm.internal
|
|
||||||
|
|
||||||
@PublishedApi
|
|
||||||
internal object Intrinsics {
|
|
||||||
@PublishedApi
|
|
||||||
@JvmStatic
|
|
||||||
internal fun checkNotNullParameter(expr: java.lang.Object?, name: String?) {
|
|
||||||
if (expr == null)
|
|
||||||
throw java.lang.NullPointerException(name)
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,11 @@
|
|||||||
|
package ru.landgrafhomyak.utility.highlevel_try_finally
|
||||||
|
|
||||||
|
@PublishedApi
|
||||||
|
internal actual object ExceptionsKt {
|
||||||
|
@PublishedApi
|
||||||
|
internal actual fun addSuppressed(e1: Throwable?, e2: Throwable?) {
|
||||||
|
if (e1 == null) throw NullPointerException("e1")
|
||||||
|
if (e2 == null) throw NullPointerException("e2")
|
||||||
|
(java.lang.Throwable::addSuppressed)(e1 as java.lang.Throwable, e2)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package ru.landgrafhomyak.utility.highlevel_try_finally
|
||||||
|
|
||||||
|
import kotlin.addSuppressed as kotlinAddSuppressed
|
||||||
|
|
||||||
|
@PublishedApi
|
||||||
|
internal actual object ExceptionsKt {
|
||||||
|
@PublishedApi
|
||||||
|
internal actual fun addSuppressed(e1: Throwable?, e2: Throwable?) {
|
||||||
|
e1!!.kotlinAddSuppressed(e2!!)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user