Fixes to remove kotlin-stdlib dependency

This commit is contained in:
Andrew Golovashevich 2025-08-24 17:15:55 +03:00
parent c078394921
commit 7d56a44323
4 changed files with 15 additions and 13 deletions

View File

@ -64,13 +64,13 @@ xomrk {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
implementation(kotlinStdlibDependency) compileOnly(kotlinStdlibDependency)
implementation("ru.landgrafhomyak.utility:highlevel-try-finally:0.6") implementation("ru.landgrafhomyak.utility:highlevel-try-finally:0.6")
} }
} }
val commonTest by getting { val commonTest by getting {
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-test:${this@kotlin.coreLibrariesVersion}") compileOnly("org.jetbrains.kotlin:kotlin-test:${this@kotlin.coreLibrariesVersion}")
} }
} }
@ -80,6 +80,12 @@ xomrk {
} }
} }
jvmTest {
dependencies {
implementation("org.testng:testng:7.5.1")
}
}
val nonJvmMain by creating { val nonJvmMain by creating {
dependsOn(commonMain) dependsOn(commonMain)
dependencies { dependencies {
@ -88,11 +94,6 @@ xomrk {
} }
} }
jvmTest {
dependencies {
implementation("org.testng:testng:7.5.1")
}
}
configureEach { configureEach {
when { when {

View File

@ -31,9 +31,8 @@ public sealed class ChildCloseableState<T : CloseableState> : CloseableState {
@ManualStateManipulation @ManualStateManipulation
override fun close() { override fun close() {
this._parent.tryFinishUsage { this._state.finishUsage()
this._state.finishUsage() this._parent.finishUsage()
}
} }
abstract override fun toString(): String abstract override fun toString(): String

View File

@ -9,6 +9,7 @@ import ru.landgrafhomyak.utility.highlevel_try_finally.safeAutoClose1
import ru.landgrafhomyak.utility.highlevel_try_finally.safeAutoClose2 import ru.landgrafhomyak.utility.highlevel_try_finally.safeAutoClose2
@OptIn(ManualStateManipulation::class) @OptIn(ManualStateManipulation::class)
@JvmName("autoClosed\$kt")
public inline fun <S : CloseableState, R> autoClosed( public inline fun <S : CloseableState, R> autoClosed(
constructor: () -> S, constructor: () -> S,
scope: (S) -> R, scope: (S) -> R,
@ -31,7 +32,7 @@ public inline fun <R> CloseableState.withUse(block: () -> R): R {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
this.startUsage() this.startUsage()
return safeAutoClose1(action = block, finally = this::finishUsage) return safeAutoClose1(action = block, finally = { this.finishUsage() })
} }
@ -42,7 +43,7 @@ public inline fun <R> CloseableState.tryStartUsage(block: () -> R): R {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
this.startUsage() this.startUsage()
return safeAutoClose2(action = block, onError = this::finishUsage) return safeAutoClose2(action = block, onError ={ this.finishUsage() })
} }
@ManualStateManipulation @ManualStateManipulation

View File

@ -2,3 +2,4 @@ package ru.landgrafhomyak.utility.closeable_state_1
public actual typealias UsagesCounter = jUsagesCounter public actual typealias UsagesCounter = jUsagesCounter
public actual typealias ErrorOnConcurrentAccessState = jErrorOnConcurrentAccessState public actual typealias ErrorOnConcurrentAccessState = jErrorOnConcurrentAccessState
public actual typealias CloseableStateCloseableWrapper = jCloseableStateCloseableWrapper