[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.InvocationKind
import kotlin.contracts.contract import kotlin.contracts.contract
@Suppress("WRONG_INVOCATION_KIND")
inline fun <R> safeAutoClose1( inline fun <R> safeAutoClose1(
finally: () -> Unit, finally: () -> Unit,
action: () -> R action: () -> R
): R { ): R {
@Suppress("WRONG_INVOCATION_KIND")
contract { contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE) callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(finally, 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) return safeAutoClose3(onError = finally, onSuccess = finally, onCrossReturn = finally, action = action)
} }
@Suppress("WRONG_INVOCATION_KIND")
inline fun <R> safeAutoClose2( inline fun <R> safeAutoClose2(
onError: () -> Unit = {}, onError: () -> Unit = {},
onSuccess: () -> Unit = {}, onSuccess: () -> Unit = {},
action: () -> R action: () -> R
): R { ): R {
@Suppress("WRONG_INVOCATION_KIND")
contract { contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE) callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(onError, InvocationKind.AT_MOST_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) return safeAutoClose3(onError = onError, onSuccess = onSuccess, onCrossReturn = onSuccess, action = action)
} }
@Suppress("WRONG_INVOCATION_KIND")
inline fun <R> safeAutoClose2e( inline fun <R> safeAutoClose2e(
onError: (Throwable) -> Unit = {}, onError: (Throwable) -> Unit = { _ -> },
onSuccess: () -> Unit = {}, onSuccess: () -> Unit = {},
action: () -> R action: () -> R
): R { ): R {
@Suppress("WRONG_INVOCATION_KIND")
contract { contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE) callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(onError, InvocationKind.AT_MOST_ONCE) callsInPlace(onError, InvocationKind.AT_MOST_ONCE)
@ -60,7 +60,7 @@ inline fun <R> safeAutoClose3(
} }
inline fun <R> safeAutoClose3e( inline fun <R> safeAutoClose3e(
onError: (Throwable) -> Unit = {}, onError: (Throwable) -> Unit = { _ -> },
onSuccess: () -> Unit = {}, onSuccess: () -> Unit = {},
onCrossReturn: () -> Unit = {}, onCrossReturn: () -> Unit = {},
action: () -> R action: () -> R