Move all coroutine-related declarations from built-ins to stdlib

Also move internal declarations from runtime.jvm module into new package
kotlin.coroutines.jvm.internal in stdlib

The necessity of these declarations being in built-ins is controversial,
but also it will complicate the migration of current coroutine runtime
to a separate jar if we ever need this
This commit is contained in:
Denis Zharkov
2017-01-26 12:24:02 +03:00
parent b61c152b4e
commit 0e132b9857
32 changed files with 212 additions and 150 deletions
@@ -20,11 +20,14 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.module
val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn")
val SUSPENDED_MARKER_NAME = Name.identifier("SUSPENDED_MARKER")
val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"))
fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean {
if (name != SUSPEND_COROUTINE_OR_RETURN_NAME) return false
@@ -36,6 +39,6 @@ fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean {
}
fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() =
builtIns.builtInsCoroutineIntrinsicsPackageFragment.getMemberScope()
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull()