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
@@ -54,6 +54,7 @@ compileKotlinCommon {
|
||||
"-module-name", project.name,
|
||||
"-Xuse-experimental=kotlin.Experimental",
|
||||
"-Xuse-experimental=kotlin.ExperimentalUnsignedTypes",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-XXLanguage:+InlineClasses",
|
||||
"-Xallow-kotlin-package"
|
||||
]
|
||||
@@ -66,6 +67,7 @@ compileCoroutinesKotlinCommon {
|
||||
apiVersion = "1.3"
|
||||
freeCompilerArgs = [
|
||||
"-module-name", project.name+"-coroutines",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-Xallow-kotlin-package"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.contracts.*
|
||||
import kotlin.internal.InlineOnly
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.jvm.JvmField
|
||||
|
||||
/**
|
||||
|
||||
@@ -149,6 +149,7 @@ compileKotlin2Js {
|
||||
freeCompilerArgs += [
|
||||
"-source-map-base-dirs", [builtinsSrcDir, jsSrcDir, commonSrcDir, commonSrcDir2].collect { file(it).absoluteFile }.join(File.pathSeparator),
|
||||
"-Xuse-experimental=kotlin.Experimental",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-XXLanguage:+InlineClasses",
|
||||
"-XXLanguage:-ReleaseCoroutines"
|
||||
]
|
||||
@@ -174,6 +175,9 @@ compileCoroutinesKotlin2Js {
|
||||
outputFile = "${buildDir}/classes/coroutines/kotlin.js"
|
||||
sourceMap = true
|
||||
sourceMapPrefix = "./"
|
||||
freeCompilerArgs += [
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.*
|
||||
|
||||
|
||||
@Deprecated("Use Synchronized annotation from kotlin.jvm package", ReplaceWith("kotlin.jvm.Synchronized"), level = DeprecationLevel.WARNING)
|
||||
|
||||
@@ -33,8 +33,8 @@ val copySources by task<Sync> {
|
||||
from(stdlibProjectDir.resolve("../src"))
|
||||
.include("kotlin/util/Standard.kt",
|
||||
"kotlin/internal/Annotations.kt",
|
||||
"kotlin/internal/contracts/ContractBuilder.kt",
|
||||
"kotlin/internal/contracts/Effect.kt")
|
||||
"kotlin/contracts/ContractBuilder.kt",
|
||||
"kotlin/contracts/Effect.kt")
|
||||
into(File(buildDir, "src"))
|
||||
}
|
||||
|
||||
@@ -46,7 +46,13 @@ tasks.withType<JavaCompile> {
|
||||
tasks.withType<KotlinCompile> {
|
||||
dependsOn(copySources)
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += listOf("-module-name", "kotlin-stdlib", "-Xmulti-platform")
|
||||
freeCompilerArgs += listOf(
|
||||
"-module-name",
|
||||
"kotlin-stdlib",
|
||||
"-Xmulti-platform",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-Xuse-experimental=kotlin.Experimental"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@ compileKotlin {
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-module-name", "kotlin-stdlib",
|
||||
"-Xuse-experimental=kotlin.Experimental",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-XXLanguage:-ReleaseCoroutines",
|
||||
"-XXLanguage:+InlineClasses"
|
||||
]
|
||||
@@ -211,6 +212,7 @@ compileCoroutinesKotlin {
|
||||
"-version",
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-module-name", "kotlin-stdlib-coroutines"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
@file:kotlin.jvm.JvmName("StandardKt")
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.contracts.*
|
||||
import kotlin.jvm.internal.unsafe.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -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