From b9e02d68f8885795c209e264e285138e2e1f6881 Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich <landgrafhomyak@gmail.com> Date: Wed, 19 Mar 2025 03:47:37 +0300 Subject: [PATCH] [history] Minor warning fixes --- .../highlevel_try_finally/safe_autoclose.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/highlevel_try_finally/safe_autoclose.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/highlevel_try_finally/safe_autoclose.kt index 16f5a43..4bfdc95 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/highlevel_try_finally/safe_autoclose.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/highlevel_try_finally/safe_autoclose.kt @@ -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