Publish ContractsDsl
- Mark @ContractsDsl as @Experimental - Move Contracts DSL out from 'internal' package - Change visibility of ContractsDsl from 'internal' to 'public' ^KT-25274 Fixed ^KT-25495 Fixed
This commit is contained in:
committed by
Ilya Gorbunov
parent
208c3a51ab
commit
accbd07b2e
@@ -9,7 +9,7 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.*
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ package kotlin.collections
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.comparisons.compareValues
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.*
|
||||
|
||||
internal object EmptyIterator : ListIterator<Nothing> {
|
||||
override fun hasNext(): Boolean = false
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.*
|
||||
|
||||
private object EmptyMap : Map<Any?, Nothing>, Serializable {
|
||||
private const val serialVersionUID: Long = 8246714829545688274
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.contracts
|
||||
|
||||
import kotlin.internal.ContractsDsl
|
||||
import kotlin.internal.InlineOnly
|
||||
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@SinceKotlin("1.3")
|
||||
@Experimental
|
||||
public annotation class ExperimentalContracts
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface ContractBuilder {
|
||||
@ContractsDsl public fun returns(): Returns
|
||||
@ContractsDsl public fun returns(value: Any?): Returns
|
||||
@ContractsDsl public fun returnsNotNull(): ReturnsNotNull
|
||||
@ContractsDsl public fun <R> callsInPlace(lambda: Function<R>, kind: InvocationKind = InvocationKind.UNKNOWN): CallsInPlace
|
||||
}
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public enum class InvocationKind {
|
||||
@ContractsDsl AT_MOST_ONCE,
|
||||
@ContractsDsl AT_LEAST_ONCE,
|
||||
@ContractsDsl EXACTLY_ONCE,
|
||||
@ContractsDsl UNKNOWN
|
||||
}
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@InlineOnly
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
public inline fun contract(builder: ContractBuilder.() -> Unit) { }
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.contracts
|
||||
|
||||
import kotlin.internal.ContractsDsl
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface Effect
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface ConditionalEffect : Effect
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface SimpleEffect {
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
public infix fun implies(booleanExpression: Boolean): ConditionalEffect
|
||||
}
|
||||
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface Returns : SimpleEffect
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface ReturnsNotNull : SimpleEffect
|
||||
|
||||
@ContractsDsl
|
||||
@ExperimentalContracts
|
||||
@SinceKotlin("1.3")
|
||||
public interface CallsInPlace : SimpleEffect
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.internal.contracts
|
||||
|
||||
import kotlin.internal.ContractsDsl
|
||||
import kotlin.internal.InlineOnly
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface ContractBuilder {
|
||||
@ContractsDsl fun returns(): Returns
|
||||
@ContractsDsl fun returns(value: Any?): Returns
|
||||
@ContractsDsl fun returnsNotNull(): ReturnsNotNull
|
||||
@ContractsDsl fun <R> callsInPlace(lambda: Function<R>, kind: InvocationKind = InvocationKind.UNKNOWN): CallsInPlace
|
||||
}
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal enum class InvocationKind {
|
||||
@ContractsDsl AT_MOST_ONCE,
|
||||
@ContractsDsl AT_LEAST_ONCE,
|
||||
@ContractsDsl EXACTLY_ONCE,
|
||||
@ContractsDsl UNKNOWN
|
||||
}
|
||||
|
||||
@ContractsDsl
|
||||
@InlineOnly
|
||||
@SinceKotlin("1.2")
|
||||
internal inline fun contract(builder: ContractBuilder.() -> Unit) { }
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.internal.contracts
|
||||
|
||||
import kotlin.internal.ContractsDsl
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface Effect
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface ConditionalEffect : Effect
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface SimpleEffect {
|
||||
@ContractsDsl
|
||||
infix fun implies(booleanExpression: Boolean): ConditionalEffect
|
||||
}
|
||||
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface Returns : SimpleEffect
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface ReturnsNotNull : SimpleEffect
|
||||
|
||||
@ContractsDsl
|
||||
@SinceKotlin("1.2")
|
||||
internal interface CallsInPlace : SimpleEffect
|
||||
@@ -11,7 +11,7 @@ package kotlin.text
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.comparisons.*
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.contract
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.contract
|
||||
|
||||
/**
|
||||
* Throws an [IllegalArgumentException] if the [value] is false.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
@file:kotlin.jvm.JvmName("StandardKt")
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.*
|
||||
|
||||
/**
|
||||
* An exception is thrown to indicate that a method body remains to be implemented.
|
||||
|
||||
Reference in New Issue
Block a user