Package kotlin.contracts

Experimental DSL for declaring custom function contracts.

Types

CallsInPlace
Link copied to clipboard
interface CallsInPlace : Effect

An effect of calling a functional parameter in place.

Since Kotlin

1.3
ConditionalEffect
Link copied to clipboard
interface ConditionalEffect : Effect

An effect of some condition being true after observing another effect of a function.

Since Kotlin

1.3
ContractBuilder
Link copied to clipboard
interface ContractBuilder

Provides a scope, where the functions of the contract DSL, such as returns, callsInPlace, etc., can be used to describe the contract of a function.

Since Kotlin

1.3
Effect
Link copied to clipboard
interface Effect

Represents an effect of a function invocation, either directly observable, such as the function returning normally, or a side-effect, such as the function's lambda parameter being called in place.

Since Kotlin

1.3
ExperimentalContracts
Link copied to clipboard
annotation class ExperimentalContracts

This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions.

Since Kotlin

1.3
InvocationKind
Link copied to clipboard
enum InvocationKind : Enum<InvocationKind>

Specifies how many times a function invokes its function parameter in place.

Since Kotlin

1.3
Returns
Link copied to clipboard
interface Returns : SimpleEffect

Describes a situation when a function returns normally with a given return value.

Since Kotlin

1.3
ReturnsNotNull
Link copied to clipboard
interface ReturnsNotNull : SimpleEffect

Describes a situation when a function returns normally with any non-null return value.

Since Kotlin

1.3
SimpleEffect
Link copied to clipboard
interface SimpleEffect : Effect

An effect that can be observed after a function invocation.

Since Kotlin

1.3

Functions

contract
Link copied to clipboard
inline fun contract(builder: ContractBuilder.() -> Unit)

Specifies the contract of a function.

Since Kotlin

1.3