mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
- Add ContractDescriptorRenderer - Add option to dump function contracts in DescriptorRendererOptions - Add parsing of LANGUAGE_VERSION directive in AbstractLoadJava - Add tests on serialization-deserializaton identity of contracts ========== Introduction of EffectSystem: 13/18
33 lines
790 B
Kotlin
Vendored
33 lines
790 B
Kotlin
Vendored
// LANGUAGE_VERSION: 1.3
|
|
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
|
|
package test
|
|
|
|
import kotlin.internal.contracts.*
|
|
|
|
// this tests specifically use primitive condition (predicate/value) as the
|
|
// first argument of sequence, so that it would be optimized and embedded into message
|
|
|
|
fun embedVariable(x: Any, b: Boolean) {
|
|
contract {
|
|
returns() implies (b && x is String)
|
|
}
|
|
}
|
|
|
|
fun embedInstancePredicate(x: Any, y: Any?) {
|
|
contract {
|
|
returns() implies (x is String && y is String)
|
|
}
|
|
}
|
|
|
|
fun embedNullCheckPredicate(x: Any?, y: Int?) {
|
|
contract {
|
|
returns() implies (y != null && x is String)
|
|
}
|
|
}
|
|
|
|
fun Boolean.embedReceiverReference(b: Boolean) {
|
|
contract {
|
|
returns() implies (!this@embedReceiverReference && b)
|
|
}
|
|
} |