From 7792613f8870b74f6ab29a292cc41cbcc8b7161e Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 22 Jan 2020 21:02:46 +0300 Subject: [PATCH] Finishing touch: drop experimental coroutines sourcesets from stdlib #KT-36083 --- libraries/stdlib/common/build.gradle | 25 ---- .../js/src/coroutines.kt | 108 ------------------ .../js/src/coroutinesIntrinsics.kt | 46 -------- libraries/stdlib/js-v1/build.gradle | 44 +------ libraries/stdlib/jvm/build.gradle | 79 +------------ 5 files changed, 4 insertions(+), 298 deletions(-) delete mode 100644 libraries/stdlib/coroutines-experimental/js/src/coroutines.kt delete mode 100644 libraries/stdlib/coroutines-experimental/js/src/coroutinesIntrinsics.kt diff --git a/libraries/stdlib/common/build.gradle b/libraries/stdlib/common/build.gradle index 75166379a83..991d675861d 100644 --- a/libraries/stdlib/common/build.gradle +++ b/libraries/stdlib/common/build.gradle @@ -26,18 +26,11 @@ sourceSets { srcDir 'test' } } - coroutinesExperimental { - kotlin { -// srcDir '../coroutines-experimental/src' - } - } } dependencies { testCompile project(":kotlin-test:kotlin-test-common") testCompile project(":kotlin-test:kotlin-test-annotations-common") - - coroutinesExperimentalCompile sourceSets.main.output } compileKotlinCommon { @@ -60,22 +53,6 @@ compileKotlinCommon { } } -compileCoroutinesExperimentalKotlinCommon { - kotlinOptions { - languageVersion = "1.3" - apiVersion = "1.3" - freeCompilerArgs = [ - "-module-name", project.name+"-coroutines", - "-Xuse-experimental=kotlin.contracts.ExperimentalContracts", - "-Xuse-experimental=kotlin.Experimental", - "-Xcoroutines=enable", - "-XXLanguage:-ReleaseCoroutines", - "-Xallow-kotlin-package", - "-Xallow-result-return-type" - ] - } -} - compileTestKotlinCommon { kotlinOptions { freeCompilerArgs += [ @@ -88,13 +65,11 @@ compileTestKotlinCommon { jar { manifestAttributes(manifest, project, 'Main') - from sourceSets.coroutinesExperimental.output } task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.kotlin - from sourceSets.coroutinesExperimental.kotlin } configurations { diff --git a/libraries/stdlib/coroutines-experimental/js/src/coroutines.kt b/libraries/stdlib/coroutines-experimental/js/src/coroutines.kt deleted file mode 100644 index 9b30acc03a1..00000000000 --- a/libraries/stdlib/coroutines-experimental/js/src/coroutines.kt +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.coroutines.experimental - -import kotlin.coroutines.experimental.intrinsics.* - -@JsName("CoroutineImpl") -internal abstract class CoroutineImpl(private val resultContinuation: Continuation) : Continuation { - protected var state = 0 - protected var exceptionState = 0 - protected var result: Any? = null - protected var exception: Throwable? = null - protected var finallyPath: Array? = null - - public override val context: CoroutineContext = resultContinuation.context - - val facade: Continuation = context[ContinuationInterceptor]?.interceptContinuation(this) ?: this - - override fun resume(value: Any?) { - result = value - doResumeWrapper() - } - - override fun resumeWithException(exception: Throwable) { - state = exceptionState - this.exception = exception - doResumeWrapper() - } - - protected fun doResumeWrapper() { - processBareContinuationResume(resultContinuation) { doResume() } - } - - protected abstract fun doResume(): Any? -} - -private val UNDECIDED: Any? = Any() -private val RESUMED: Any? = Any() - -private class Fail(val exception: Throwable) - -@PublishedApi -internal actual class SafeContinuation -internal actual constructor( - private val delegate: Continuation, - initialResult: Any? -) : Continuation { - - @PublishedApi - internal actual constructor(delegate: Continuation) : this(delegate, UNDECIDED) - - public actual override val context: CoroutineContext - get() = delegate.context - - private var result: Any? = initialResult - - actual override fun resume(value: T) { - when { - result === UNDECIDED -> { - result = value - } - result === COROUTINE_SUSPENDED -> { - result = RESUMED - delegate.resume(value) - } - else -> { - throw IllegalStateException("Already resumed") - } - } - } - - actual override fun resumeWithException(exception: Throwable) { - when { - result === UNDECIDED -> { - result = Fail(exception) - } - result === COROUTINE_SUSPENDED -> { - result = RESUMED - delegate.resumeWithException(exception) - } - else -> { - throw IllegalStateException("Already resumed") - } - } - } - - @PublishedApi - internal actual fun getResult(): Any? { - if (result === UNDECIDED) { - result = COROUTINE_SUSPENDED - } - val result = this.result - return when { - result === RESUMED -> { - COROUTINE_SUSPENDED // already called continuation, indicate SUSPENDED upstream - } - result is Fail -> { - throw result.exception - } - else -> { - result // either SUSPENDED or data - } - } - } -} diff --git a/libraries/stdlib/coroutines-experimental/js/src/coroutinesIntrinsics.kt b/libraries/stdlib/coroutines-experimental/js/src/coroutinesIntrinsics.kt deleted file mode 100644 index 747a7e338fb..00000000000 --- a/libraries/stdlib/coroutines-experimental/js/src/coroutinesIntrinsics.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") - -package kotlin.coroutines.experimental.intrinsics - -import kotlin.coroutines.experimental.Continuation - -@SinceKotlin("1.1") -@Suppress("UNCHECKED_CAST") -@kotlin.internal.InlineOnly -public actual inline fun (suspend () -> T).startCoroutineUninterceptedOrReturn( - completion: Continuation -): Any? = this.asDynamic()(completion, false) - -@SinceKotlin("1.1") -@Suppress("UNCHECKED_CAST") -@kotlin.internal.InlineOnly -public actual inline fun (suspend R.() -> T).startCoroutineUninterceptedOrReturn( - receiver: R, - completion: Continuation -): Any? = this.asDynamic()(receiver, completion, false) - -@SinceKotlin("1.1") -public actual fun (suspend R.() -> T).createCoroutineUnchecked( - receiver: R, - completion: Continuation -): Continuation = this.asDynamic()(receiver, completion, true).facade - -@SinceKotlin("1.1") -public actual fun (suspend () -> T).createCoroutineUnchecked( - completion: Continuation -): Continuation = this.asDynamic()(completion, true).facade - - -/** - * This value is used as a return value of [suspendCoroutineOrReturn] `block` argument to state that - * the execution was suspended and will not return any result immediately. - */ -@SinceKotlin("1.1") -public actual val COROUTINE_SUSPENDED: Any = CoroutineSuspendedMarker - -private object CoroutineSuspendedMarker \ No newline at end of file diff --git a/libraries/stdlib/js-v1/build.gradle b/libraries/stdlib/js-v1/build.gradle index 7ddabddf9e7..771fec4ee43 100644 --- a/libraries/stdlib/js-v1/build.gradle +++ b/libraries/stdlib/js-v1/build.gradle @@ -24,10 +24,8 @@ def commonSrcDir = "${projectDir}/../src/kotlin" def commonSrcDir2 = "${projectDir}/../common/src" def jsCommonDir = "${projectDir}/../js" -def coroutinesExpJsSrcDir = "${rootDir}/libraries/stdlib/coroutines-experimental/js/src" def builtinsDir = "${rootDir}/core/builtins" def unsignedCommonSrcDir = "${rootDir}/libraries/stdlib/unsigned/src" -def coroutinesJsModuleName = 'kotlin-stdlib-coroutines' def jsSrcDir = "src" def jsCommonSrcDir = "${jsCommonDir}/src" @@ -67,19 +65,12 @@ sourceSets { srcDir jsCommonTestSrcDir } } - - coroutinesExperimental { - kotlin { -// srcDir coroutinesExpJsSrcDir - } - } } dependencies { expectedBy project(":kotlin-stdlib-common") commonSources project(path: ":kotlin-stdlib-common", configuration: "sources") testCompile project(':kotlin-test:kotlin-test-js') - coroutinesExperimentalCompile project.files { sourceSets.main.output.files }.builtBy(compileKotlin2Js) } task prepareComparableSource(type: Copy) { @@ -158,22 +149,6 @@ compileKotlin2Js { } } -compileCoroutinesExperimentalKotlin2Js { - kotlinOptions { - languageVersion = "1.3" - apiVersion = "1.3" - outputFile = "${buildDir}/classes/coroutinesExperimental/kotlin.js" - sourceMap = true - sourceMapPrefix = "./" - freeCompilerArgs += [ - "-Xuse-experimental=kotlin.contracts.ExperimentalContracts", - "-Xuse-experimental=kotlin.Experimental", - "-Xcoroutines=enable", - "-XXLanguage:-ReleaseCoroutines" - ] - } -} - compileTestKotlin2Js { kotlinOptions { moduleKind = "umd" @@ -186,10 +161,9 @@ compileTestKotlin2Js { } task compileJs(type: NoDebugJavaExec) { - dependsOn compileBuiltinsKotlin2Js, compileKotlin2Js, compileCoroutinesExperimentalKotlin2Js + dependsOn compileBuiltinsKotlin2Js, compileKotlin2Js inputs.files(compileBuiltinsKotlin2Js.outputs.files).withPathSensitivity(PathSensitivity.RELATIVE) inputs.files(compileKotlin2Js.outputs.files).withPathSensitivity(PathSensitivity.RELATIVE) - inputs.files(compileCoroutinesExperimentalKotlin2Js.outputs.files).withPathSensitivity(PathSensitivity.RELATIVE) inputs.dir(jsSrcDir).withPathSensitivity(PathSensitivity.RELATIVE) inputs.dir(jsCommonSrcDir).withPathSensitivity(PathSensitivity.RELATIVE) @@ -206,8 +180,7 @@ task compileJs(type: NoDebugJavaExec) { doFirst { args = [jsOutputFile, rootDir, "$jsSrcDir/wrapper.js"] + inputFiles.collect { it.path }.sort() + (compileBuiltinsKotlin2Js.outputs.files.collect { it.path }.sort() + - compileKotlin2Js.outputs.files.collect { it.path }.sort() /*+ - compileCoroutinesExperimentalKotlin2Js.outputs.files.collect { it.path }.sort()*/).findAll { + compileKotlin2Js.outputs.files.collect { it.path }.sort()).findAll { it.endsWith(".js") && !it.endsWith(".meta.js") } } @@ -253,8 +226,7 @@ task compileJs(type: NoDebugJavaExec) { sourceMapFile.text = groovy.json.JsonOutput.toJson(sourceMap) - file(jsOutputMetaFile).text = file(compileKotlin2Js.outputFile.path.replaceAll('\\.js$', '.meta.js')).text /*+ - file(compileCoroutinesExperimentalKotlin2Js.outputFile.path.replaceAll('\\.js$', '.meta.js')).text*/ + file(jsOutputMetaFile).text = file(compileKotlin2Js.outputFile.path.replaceAll('\\.js$', '.meta.js')).text } } @@ -283,9 +255,6 @@ task libraryJarWithoutIr(type: Jar, dependsOn: compileJs) { from jsOutputMetaFile from "${jsOutputFile}.map" from sourceSets.main.output - from("${buildDir}/classes/coroutinesExperimental/kotlin") { - into coroutinesJsModuleName - } } task libraryJarWithIr(type: Zip, dependsOn: libraryJarWithoutIr) { @@ -321,9 +290,6 @@ task sourcesJar(type: Jar, dependsOn: compileJs) { from(sourceSets.main.allSource) { include 'org.w3c/**' } - from(sourceSets.coroutinesExperimental.allSource) { - into 'kotlin' - } } task distSourcesJar(type: Jar) { @@ -338,10 +304,6 @@ task distSourcesJar(type: Jar) { exclude 'META-INF/*' into 'common' } - - from(project(":kotlin-stdlib-common").sourceSets.coroutinesExperimental.allSource) { - into 'kotlin' - } } def javadocJar = javadocJar() diff --git a/libraries/stdlib/jvm/build.gradle b/libraries/stdlib/jvm/build.gradle index f18bd399457..b5e6094f126 100644 --- a/libraries/stdlib/jvm/build.gradle +++ b/libraries/stdlib/jvm/build.gradle @@ -24,23 +24,6 @@ sourceSets { srcDir 'src' } } - coroutinesExperimental { - kotlin { -// srcDir '../coroutines-experimental/jvm/src' - } - } - coroutinesExperimentalTest { - kotlin { -// srcDir '../coroutines-experimental/jvm/test' - } - } - coroutinesExperimentalMigrationTest { - kotlin { - if(!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync) { -// srcDir '../coroutines-experimental/jvm/test' - } - } - } test { kotlin { srcDir 'test' @@ -60,12 +43,9 @@ sourceSets { configurations { commonSources - coroutinesExperimentalTestCompile.extendsFrom(testCompile) - coroutinesExperimentalMigrationTestCompile.extendsFrom(coroutinesExperimentalTestCompile) longRunningTestCompile.extendsFrom(testCompile) builtins compileOnly.extendsFrom(builtins) - coroutinesExperimentalCompile.extendsFrom(builtins) } dependencies { @@ -76,12 +56,8 @@ dependencies { compile group: 'org.jetbrains', name: 'annotations', version:'13.0' testCompile project(':kotlin-test:kotlin-test-junit') - testCompile sourceSets.coroutinesExperimental.output testCompile project(':kotlin-coroutines-experimental-compat') - coroutinesExperimentalCompile sourceSets.main.output - coroutinesExperimentalTestCompile sourceSets.test.output - builtins project(':core:builtins') } @@ -91,14 +67,12 @@ jar { from { zipTree(configurations.builtins.singleFile) } - from sourceSets.coroutinesExperimental.output // TODO: enable as soon as this doesn't cause D8/DX to crash // from sourceSets.java9.output } sourcesJar { from "${rootDir}/core/builtins/native" - from sourceSets.coroutinesExperimental.kotlin } task distSourcesJar(type: Jar) { @@ -161,58 +135,7 @@ compileKotlin { } -compileJava9Sources(project, 'kotlin.stdlib', [sourceSets.main.output, sourceSets.coroutinesExperimental.output]) - -compileCoroutinesExperimentalKotlin { - kotlinOptions { - languageVersion = "1.3" - apiVersion = "1.3" - freeCompilerArgs = [ - "-version", - "-Xallow-kotlin-package", - "-Xallow-result-return-type", - "-Xmultifile-parts-inherit", - "-Xuse-experimental=kotlin.contracts.ExperimentalContracts", - "-Xuse-experimental=kotlin.Experimental", - "-Xcoroutines=enable", - "-XXLanguage:-ReleaseCoroutines", - "-Xno-use-ir", - "-module-name", "kotlin-stdlib-coroutines" - ] - } -} - -compileCoroutinesExperimentalTestKotlin { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - freeCompilerArgs = [ - "-Xcoroutines=enable" - ] - } -} - -compileCoroutinesExperimentalMigrationTestKotlin { - kotlinOptions { - languageVersion = "1.3" - apiVersion = "1.3" - freeCompilerArgs = [] - } -} - -task coroutinesExperimentalTest(type: Test, dependsOn: coroutinesExperimentalTestClasses) { - group = "verification" - testClassesDirs = sourceSets.coroutinesExperimentalTest.output.classesDirs - classpath = sourceSets.coroutinesExperimentalTest.runtimeClasspath -} -task coroutinesExperimentalMigrationTest(type: Test, dependsOn: coroutinesExperimentalMigrationTestClasses) { - group = "verification" - testClassesDirs = sourceSets.coroutinesExperimentalMigrationTest.output.classesDirs - classpath = sourceSets.coroutinesExperimentalMigrationTest.runtimeClasspath -} - -check.dependsOn(coroutinesExperimentalTest) -check.dependsOn(coroutinesExperimentalMigrationTest) +compileJava9Sources(project, 'kotlin.stdlib', [sourceSets.main.output]) compileTestKotlin { kotlinOptions {