diego-gomez-olvera
01/30/2024, 4:29 PMpublic expect inline fun <T> synchronized(lock: SynchronizedObject, block: () -> T): T
as replacement of JVM synchronized
misses
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
making the compiler unable to infer this. Is it possible to combine expect
functions with contacts?diego-gomez-olvera
01/30/2024, 4:30 PMactual
implementations, of course, but there's no guarantee that all of them respect the contract
ephemient
01/31/2024, 3:10 PMpublic inline fun <T> synchronized(lock: SynchronizedObject, block: () -> T): T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return platformSynchronized(lock, block)
}
internal expect fun <T> platformSynchronized(lock: SynchronizedObject, block: () -> T): T
at least until https://youtrack.jetbrains.com/issue/KT-56127/K2-Provide-new-stable-syntax-for-contractsdiego-gomez-olvera
01/31/2024, 3:13 PM