[history] Minor warning fixes

This commit is contained in:
Andrew Golovashevich 2025-03-19 03:47:37 +03:00
parent b2a5ac9292
commit b9e02d68f8

View File

@ -3,11 +3,11 @@ package ru.landgrafhomyak.utility.highlevel_try_finally
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
@Suppress("WRONG_INVOCATION_KIND")
inline fun <R> safeAutoClose1(
finally: () -> Unit,
action: () -> R
): R {
@Suppress("WRONG_INVOCATION_KIND")
): R {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(finally, InvocationKind.EXACTLY_ONCE)
@ -15,12 +15,12 @@ inline fun <R> safeAutoClose1(
return safeAutoClose3(onError = finally, onSuccess = finally, onCrossReturn = finally, action = action)
}
@Suppress("WRONG_INVOCATION_KIND")
inline fun <R> safeAutoClose2(
onError: () -> Unit = {},
onSuccess: () -> Unit = {},
action: () -> R
): R {
@Suppress("WRONG_INVOCATION_KIND")
): R {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(onError, InvocationKind.AT_MOST_ONCE)
@ -29,12 +29,12 @@ inline fun <R> safeAutoClose2(
return safeAutoClose3(onError = onError, onSuccess = onSuccess, onCrossReturn = onSuccess, action = action)
}
@Suppress("WRONG_INVOCATION_KIND")
inline fun <R> safeAutoClose2e(
onError: (Throwable) -> Unit = {},
onError: (Throwable) -> Unit = { _ -> },
onSuccess: () -> Unit = {},
action: () -> R
): R {
@Suppress("WRONG_INVOCATION_KIND")
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(onError, InvocationKind.AT_MOST_ONCE)
@ -60,7 +60,7 @@ inline fun <R> safeAutoClose3(
}
inline fun <R> safeAutoClose3e(
onError: (Throwable) -> Unit = {},
onError: (Throwable) -> Unit = { _ -> },
onSuccess: () -> Unit = {},
onCrossReturn: () -> Unit = {},
action: () -> R