Files
Dmitriy Dolovov d30efdb001 [kotlinp] Split :tools:kotlinp into "common" and "jvm" subprojects
The "common" subproject keeps only backend-neutral logic and depends
only on :kotlinx-metadata library. It takes the name of the former
project - :tools:kotlinp

The "jvm" subproject depends on the "common" one and also depends
on :kotlinx-metadata-jvm. It gets the new name - :tools:kotlinp-jvm

There is a lot of touched files in this commit. The majority of them
is just moved files (tests, test data, etc).

Only the following files were actually modified:
  .space/CODEOWNERS
  build.gradle.kts
  libraries/tools/abi-comparator/build.gradle.kts
  libraries/tools/kotlinp/build.gradle.kts
  libraries/tools/kotlinp/jvm/build.gradle.kts
  plugins/kapt3/kapt3-compiler/build.gradle.kts
  settings.gradle

 ^KT-62340
2024-02-13 21:01:08 +00:00

67 lines
1.4 KiB
Kotlin
Vendored

@file:OptIn(ExperimentalContracts::class)
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import kotlin.contracts.ExperimentalContracts
fun returnsTrue(condition: Boolean) {
contract {
returns(true) implies (condition)
}
}
fun returnsNull(condition: Boolean) {
contract {
returns(null) implies (condition)
}
}
fun returnsNotNull(condition: Boolean) {
contract {
returnsNotNull() implies (condition)
}
}
fun Any?.receiverIsNotNull(): Boolean {
contract {
returns(true) implies (this@receiverIsNotNull != null)
}
return this != null
}
inline fun callsInPlaceAtMostOnce(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
}
}
inline fun callsInPlaceUnknown(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.UNKNOWN)
}
}
fun conjunction(a: Boolean, b: Boolean, c: Boolean) {
contract {
returns() implies (a && !b && c)
}
}
fun disjunction(a: Boolean, b: Boolean, c: Boolean) {
contract {
returns() implies (a || !b || c)
}
}
fun complexBoolean(a: Any?, b: Any?, c: Any?, d: Any?) {
contract {
returns() implies ((a != null && c != null) || (b == null && d != null))
}
}
fun negatedIsAndConjunction(a: Any?, b: Boolean, c: Any?) {
contract {
returns() implies (a !is List<*> && b && c == null)
}
}