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
@@ -74,6 +74,7 @@ enum class LanguageFeature(
|
||||
ReadDeserializedContracts(KOTLIN_1_3),
|
||||
UseReturnsEffect(KOTLIN_1_3),
|
||||
UseCallsInPlaceEffect(KOTLIN_1_3),
|
||||
AllowContractsForCustomFunctions(KOTLIN_1_3),
|
||||
VariableDeclarationInWhenSubject(KOTLIN_1_3),
|
||||
ProhibitLocalAnnotations(KOTLIN_1_3, kind = BUG_FIX),
|
||||
ProhibitSmartcastsOnLocalDelegatedProperty(KOTLIN_1_3, kind = BUG_FIX),
|
||||
@@ -100,8 +101,6 @@ enum class LanguageFeature(
|
||||
State.ENABLED_WITH_WARNING
|
||||
),
|
||||
|
||||
AllowContractsForCustomFunctions(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE),
|
||||
|
||||
MultiPlatformProjects(sinceVersion = null, defaultState = State.DISABLED),
|
||||
|
||||
NewInference(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED),
|
||||
|
||||
@@ -36,7 +36,8 @@ compileKotlinCommon {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = [
|
||||
"-module-name", project.name,
|
||||
"-Xallow-kotlin-package"
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
package kotlin.test
|
||||
|
||||
import kotlin.contracts.*
|
||||
import kotlin.internal.*
|
||||
import kotlin.internal.contracts.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ dependencies {
|
||||
}
|
||||
|
||||
compileKotlin2Js {
|
||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xuse-experimental=kotlin.contracts.ExperimentalContracts"]
|
||||
kotlinOptions {
|
||||
moduleKind = "umd"
|
||||
outputFile = "${buildDir}/classes/main/kotlin-test.js"
|
||||
|
||||
@@ -41,7 +41,8 @@ dist {
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xnormalize-constructor-calls=enable",
|
||||
"-module-name", project.archivesBaseName]
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-module-name", project.archivesBaseName, ]
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
|
||||
@@ -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.
|
||||
|
||||
+42
@@ -2539,6 +2539,48 @@ public final class kotlin/concurrent/TimersKt {
|
||||
public static final fun timer (Ljava/lang/String;Z)Ljava/util/Timer;
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/CallsInPlace : kotlin/contracts/SimpleEffect {
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/ConditionalEffect : kotlin/contracts/Effect {
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/ContractBuilder {
|
||||
public abstract fun callsInPlace (Lkotlin/Function;Lkotlin/contracts/InvocationKind;)Lkotlin/contracts/CallsInPlace;
|
||||
public abstract fun returns ()Lkotlin/contracts/Returns;
|
||||
public abstract fun returns (Ljava/lang/Object;)Lkotlin/contracts/Returns;
|
||||
public abstract fun returnsNotNull ()Lkotlin/contracts/ReturnsNotNull;
|
||||
}
|
||||
|
||||
public final class kotlin/contracts/ContractBuilder$DefaultImpls {
|
||||
public static synthetic fun callsInPlace$default (Lkotlin/contracts/ContractBuilder;Lkotlin/Function;Lkotlin/contracts/InvocationKind;ILjava/lang/Object;)Lkotlin/contracts/CallsInPlace;
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/Effect {
|
||||
}
|
||||
|
||||
public abstract interface annotation class kotlin/contracts/ExperimentalContracts : java/lang/annotation/Annotation {
|
||||
}
|
||||
|
||||
public final class kotlin/contracts/InvocationKind : java/lang/Enum {
|
||||
public static final field AT_LEAST_ONCE Lkotlin/contracts/InvocationKind;
|
||||
public static final field AT_MOST_ONCE Lkotlin/contracts/InvocationKind;
|
||||
public static final field EXACTLY_ONCE Lkotlin/contracts/InvocationKind;
|
||||
public static final field UNKNOWN Lkotlin/contracts/InvocationKind;
|
||||
public static fun valueOf (Ljava/lang/String;)Lkotlin/contracts/InvocationKind;
|
||||
public static fun values ()[Lkotlin/contracts/InvocationKind;
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/Returns : kotlin/contracts/SimpleEffect {
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/ReturnsNotNull : kotlin/contracts/SimpleEffect {
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/contracts/SimpleEffect {
|
||||
public abstract fun implies (Z)Lkotlin/contracts/ConditionalEffect;
|
||||
}
|
||||
|
||||
public abstract class kotlin/coroutines/AbstractCoroutineContextElement : kotlin/coroutines/CoroutineContext$Element {
|
||||
public fun <init> (Lkotlin/coroutines/CoroutineContext$Key;)V
|
||||
public fun fold (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
|
||||
|
||||
Reference in New Issue
Block a user