Move coroutineContext to correct package
from kotlin.coroutines.experimental.instrinsics to kotlin.coroutines.experimental #KT-22400
This commit is contained in:
+7
-6
@@ -22,7 +22,9 @@ import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.COROUTINE_CONTEXT_1_2_20_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.COROUTINE_CONTEXT_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
|
||||
@@ -30,9 +32,6 @@ val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn
|
||||
val INTERCEPTED_NAME = Name.identifier("intercepted")
|
||||
val COROUTINE_SUSPENDED_NAME = Name.identifier("COROUTINE_SUSPENDED")
|
||||
|
||||
val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"))
|
||||
val COROUTINE_CONTEXT_FQ_NAME = COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
|
||||
val SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME = Name.identifier("suspendCoroutineUninterceptedOrReturn")
|
||||
|
||||
fun FunctionDescriptor.isBuiltInIntercepted(): Boolean {
|
||||
@@ -59,8 +58,10 @@ fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() =
|
||||
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull()
|
||||
|
||||
fun FunctionDescriptor.isBuiltInCoroutineContext() =
|
||||
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe == COROUTINE_CONTEXT_FQ_NAME
|
||||
fun FunctionDescriptor.isBuiltInCoroutineContext(): Boolean {
|
||||
val fqNameSafe = (this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe
|
||||
return fqNameSafe == COROUTINE_CONTEXT_1_2_20_FQ_NAME || fqNameSafe == COROUTINE_CONTEXT_FQ_NAME
|
||||
}
|
||||
|
||||
fun FunctionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(): Boolean {
|
||||
if (name != SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME) return false
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ val COROUTINE_CONTEXT_ASM_TYPE = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.chil
|
||||
val COROUTINE_IMPL_ASM_TYPE = COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineImpl")).topLevelClassAsmType()
|
||||
|
||||
private val COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME =
|
||||
COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
|
||||
DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
|
||||
|
||||
private val INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME =
|
||||
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
|
||||
|
||||
+9
-3
@@ -25,10 +25,11 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasRestrictsSuspensionAnnotation
|
||||
@@ -43,15 +44,20 @@ import org.jetbrains.kotlin.types.typeUtil.supertypes
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
val COROUTINE_CONTEXT_1_2_20_FQ_NAME = DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
val COROUTINE_CONTEXT_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
|
||||
|
||||
object CoroutineSuspendCallChecker : CallChecker {
|
||||
private val ALLOWED_SCOPE_KINDS = setOf(LexicalScopeKind.FUNCTION_INNER_SCOPE, LexicalScopeKind.FUNCTION_HEADER_FOR_DESTRUCTURING)
|
||||
private val COROUTINE_CONTEXT_FQ_NAME = FqName("kotlin.coroutines.experimental.intrinsics.coroutineContext")
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val descriptor = resolvedCall.candidateDescriptor
|
||||
when (descriptor) {
|
||||
is FunctionDescriptor -> if (!descriptor.isSuspend) return
|
||||
is PropertyDescriptor -> if (descriptor.fqNameSafe != COROUTINE_CONTEXT_FQ_NAME) return
|
||||
is PropertyDescriptor -> when (descriptor.fqNameSafe) {
|
||||
COROUTINE_CONTEXT_1_2_20_FQ_NAME, COROUTINE_CONTEXT_FQ_NAME -> {}
|
||||
else -> return
|
||||
}
|
||||
else -> return
|
||||
}
|
||||
|
||||
|
||||
+58
-11
@@ -2,19 +2,38 @@
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
suspend fun suspendHere() = if(coroutineContext != EmptyCoroutineContext) "$coroutineContext != $EmptyCoroutineContext" else "OK"
|
||||
suspend fun suspendHereOld() =
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun multipleArgs(a: Any, b: Any, c: Any) = if(coroutineContext != EmptyCoroutineContext) "$coroutineContext != $EmptyCoroutineContext" else "OK"
|
||||
suspend fun suspendHereNew() =
|
||||
if (coroutineContext != EmptyCoroutineContext)
|
||||
"${coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun multipleArgsOld(a: Any, b: Any, c: Any) =
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun multipleArgsNew(a: Any, b: Any, c: Any) =
|
||||
if (coroutineContext != EmptyCoroutineContext)
|
||||
"${coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
fun builder(c: suspend () -> String): String {
|
||||
var fromSuspension: String? = null
|
||||
|
||||
val continuation = object: Continuation<String> {
|
||||
val continuation = object : Continuation<String> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
fromSuspension = "Exception: ${exception}"
|
||||
@@ -31,12 +50,40 @@ fun builder(c: suspend () -> String): String {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = builder { suspendHere() }
|
||||
if (res != "OK") { return "fail 1 $res"}
|
||||
res = builder { multipleArgs(1,1,1) }
|
||||
if (res != "OK") { return "fail 2 $res"}
|
||||
res = builder { if(coroutineContext != EmptyCoroutineContext) "$coroutineContext != $EmptyCoroutineContext" else "OK" }
|
||||
if (res != "OK") { return "fail 3 $res"}
|
||||
var res = builder { suspendHereOld() }
|
||||
if (res != "OK") {
|
||||
return "fail 1 $res"
|
||||
}
|
||||
res = builder { multipleArgsOld(1, 1, 1) }
|
||||
if (res != "OK") {
|
||||
return "fail 2 $res"
|
||||
}
|
||||
res = builder {
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
}
|
||||
if (res != "OK") {
|
||||
return "fail 3 $res"
|
||||
}
|
||||
res = builder { suspendHereNew() }
|
||||
if (res != "OK") {
|
||||
return "fail 4 $res"
|
||||
}
|
||||
res = builder { multipleArgsNew(1, 1, 1) }
|
||||
if (res != "OK") {
|
||||
return "fail 5 $res"
|
||||
}
|
||||
res = builder {
|
||||
if (coroutineContext != EmptyCoroutineContext)
|
||||
"${coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
}
|
||||
if (res != "OK") {
|
||||
return "fail 6 $res"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+58
-10
@@ -6,16 +6,36 @@ import kotlin.coroutines.experimental.intrinsics.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class Controller {
|
||||
suspend fun controllerSuspendHere() = if(coroutineContext != EmptyCoroutineContext) "$coroutineContext != $EmptyCoroutineContext" else "OK"
|
||||
suspend fun controllerSuspendHereOld() =
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun controllerMultipleArgs(a: Any, b: Any, c: Any) = if(coroutineContext != EmptyCoroutineContext) "$coroutineContext != $EmptyCoroutineContext" else "OK"
|
||||
suspend fun controllerMultipleArgsOld(a: Any, b: Any, c: Any) =
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun controllerSuspendHereNew() =
|
||||
if (kotlin.coroutines.experimental.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun controllerMultipleArgsNew(a: Any, b: Any, c: Any) =
|
||||
if (kotlin.coroutines.experimental.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
fun builder(c: suspend Controller.() -> String): String {
|
||||
var fromSuspension: String? = null
|
||||
|
||||
c.startCoroutine(this, object: Continuation<String> {
|
||||
c.startCoroutine(this, object : Continuation<String> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
fromSuspension = "Exception: " + exception.message!!
|
||||
@@ -32,12 +52,40 @@ class Controller {
|
||||
|
||||
fun box(): String {
|
||||
val c = Controller()
|
||||
var res = c.builder { controllerSuspendHere() }
|
||||
if (res != "OK") { return "fail 1 $res"}
|
||||
res = c.builder { controllerMultipleArgs(1,1,1) }
|
||||
if (res != "OK") { return "fail 2 $res"}
|
||||
res = c.builder { if(coroutineContext != EmptyCoroutineContext) "$coroutineContext != $EmptyCoroutineContext" else "OK" }
|
||||
if (res != "OK") { return "fail 3 $res"}
|
||||
var res = c.builder { controllerSuspendHereOld() }
|
||||
if (res != "OK") {
|
||||
return "fail 1 $res"
|
||||
}
|
||||
res = c.builder { controllerMultipleArgsOld(1, 1, 1) }
|
||||
if (res != "OK") {
|
||||
return "fail 2 $res"
|
||||
}
|
||||
res = c.builder {
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
}
|
||||
if (res != "OK") {
|
||||
return "fail 3 $res"
|
||||
}
|
||||
res = c.builder { controllerSuspendHereNew() }
|
||||
if (res != "OK") {
|
||||
return "fail 4 $res"
|
||||
}
|
||||
res = c.builder { controllerMultipleArgsNew(1, 1, 1) }
|
||||
if (res != "OK") {
|
||||
return "fail 5 $res"
|
||||
}
|
||||
res = c.builder {
|
||||
if (kotlin.coroutines.experimental.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
}
|
||||
if (res != "OK") {
|
||||
return "fail 6 $res"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+36
-15
@@ -15,21 +15,30 @@ class Controller {
|
||||
public override fun toString(): String = "AnotherEmptyCoroutineContext"
|
||||
}
|
||||
|
||||
suspend fun controllerSuspendHere() = if(coroutineContext == EmptyCoroutineContext) "$coroutineContext == $EmptyCoroutineContext" else "OK"
|
||||
suspend fun controllerSuspendHere() =
|
||||
if (coroutineContext == EmptyCoroutineContext) "$coroutineContext == $EmptyCoroutineContext" else "OK"
|
||||
|
||||
suspend fun controllerSuspendHereIntrinsic() = if(kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
suspend fun controllerSuspendHereIntrinsicOld() =
|
||||
if (kotlin.coroutines.experimental.intrinsics.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.intrinsics.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun controllerMultipleArgs(a: Any, b: Any, c: Any) = if(coroutineContext == EmptyCoroutineContext) "$coroutineContext == $EmptyCoroutineContext" else "OK"
|
||||
suspend fun controllerSuspendHereIntrinsicNew() =
|
||||
if (kotlin.coroutines.experimental.coroutineContext != EmptyCoroutineContext)
|
||||
"${kotlin.coroutines.experimental.coroutineContext} != $EmptyCoroutineContext"
|
||||
else
|
||||
"OK"
|
||||
|
||||
suspend fun controllerMultipleArgs(a: Any, b: Any, c: Any) =
|
||||
if (coroutineContext == EmptyCoroutineContext) "$coroutineContext == $EmptyCoroutineContext" else "OK"
|
||||
|
||||
fun builder(c: suspend Controller.() -> String): String {
|
||||
var fromSuspension: String? = null
|
||||
|
||||
c.startCoroutine(this, object: Continuation<String> {
|
||||
c.startCoroutine(this, object : Continuation<String> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
fromSuspension = "Exception: " + exception.message!!
|
||||
@@ -46,14 +55,26 @@ class Controller {
|
||||
|
||||
fun box(): String {
|
||||
val v = Controller()
|
||||
var res = v.builder { controllerMultipleArgs(1,1,1) }
|
||||
if (res != "OK") { return "fail 1 $res"}
|
||||
res = v.builder { if(coroutineContext == EmptyCoroutineContext) "$coroutineContext == $EmptyCoroutineContext" else "OK" }
|
||||
if (res != "OK") { return "fail 2 $res"}
|
||||
res = v.builder { controllerSuspendHereIntrinsic() }
|
||||
if (res != "OK") { return "fail 3 $res"}
|
||||
var res = v.builder { controllerMultipleArgs(1, 1, 1) }
|
||||
if (res != "OK") {
|
||||
return "fail 1 $res"
|
||||
}
|
||||
res = v.builder { if (coroutineContext == EmptyCoroutineContext) "$coroutineContext == $EmptyCoroutineContext" else "OK" }
|
||||
if (res != "OK") {
|
||||
return "fail 2 $res"
|
||||
}
|
||||
res = v.builder { controllerSuspendHereIntrinsicOld() }
|
||||
if (res != "OK") {
|
||||
return "fail 3 $res"
|
||||
}
|
||||
res = v.builder { controllerSuspendHereIntrinsicNew() }
|
||||
if (res != "OK") {
|
||||
return "fail 4 $res"
|
||||
}
|
||||
res = v.builder { controllerSuspendHere() }
|
||||
if (res != "OK") { return "fail 4 $res"}
|
||||
if (res != "OK") {
|
||||
return "fail 5 $res"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -6,8 +6,12 @@ suspend fun suspendHere(ctx: CoroutineContext) = suspendCoroutineOrReturn<String
|
||||
if (x.context == ctx) x.resume("OK") else x.resume("FAIL")
|
||||
}
|
||||
|
||||
suspend fun mustBeTailCall(): String {
|
||||
return suspendHere(coroutineContext)
|
||||
suspend fun mustBeTailCallOld(): String {
|
||||
return suspendHere(kotlin.coroutines.experimental.intrinsics.coroutineContext)
|
||||
}
|
||||
|
||||
suspend fun mustBeTailCallNew(): String {
|
||||
return suspendHere(kotlin.coroutines.experimental.coroutineContext)
|
||||
}
|
||||
|
||||
suspend fun retrieveCoroutineContext(): CoroutineContext =
|
||||
|
||||
@@ -12,7 +12,8 @@ final class CoroutineContextIntrinsicKt$notTailCall$1 {
|
||||
@kotlin.Metadata
|
||||
public final class CoroutineContextIntrinsicKt {
|
||||
inner class CoroutineContextIntrinsicKt$notTailCall$1
|
||||
public final static @org.jetbrains.annotations.Nullable method mustBeTailCall(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||
public final static @org.jetbrains.annotations.Nullable method mustBeTailCallNew(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||
public final static @org.jetbrains.annotations.Nullable method mustBeTailCallOld(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||
public final static @org.jetbrains.annotations.Nullable method notTailCall(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||
public final static @org.jetbrains.annotations.Nullable method retrieveCoroutineContext(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||
public final static @org.jetbrains.annotations.Nullable method suspendHere(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.CoroutineContext, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||
|
||||
+23
-3
@@ -1,30 +1,42 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// SKIP_TXT
|
||||
|
||||
import kotlin.coroutines.experimental.intrinsics.coroutineContext
|
||||
import kotlin.coroutines.experimental.CoroutineContext
|
||||
import kotlin.coroutines.experimental.*
|
||||
|
||||
fun ordinal() {
|
||||
kotlin.coroutines.experimental.intrinsics.<!DEPRECATION, ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
kotlin.coroutines.experimental.<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
}
|
||||
|
||||
suspend fun named() {
|
||||
kotlin.coroutines.experimental.intrinsics.<!DEPRECATION!>coroutineContext<!>
|
||||
kotlin.coroutines.experimental.coroutineContext
|
||||
coroutineContext
|
||||
}
|
||||
|
||||
class A {
|
||||
val coroutineContext = kotlin.coroutines.experimental.intrinsics.<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
val coroutineContextOld = kotlin.coroutines.experimental.intrinsics.<!DEPRECATION, ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
val coroutineContextNew = kotlin.coroutines.experimental.<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
val context = <!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
}
|
||||
|
||||
class Controller {
|
||||
fun ordinal() {
|
||||
kotlin.coroutines.experimental.intrinsics.<!DEPRECATION, ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
kotlin.coroutines.experimental.<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!>
|
||||
}
|
||||
|
||||
suspend fun named() {
|
||||
kotlin.coroutines.experimental.intrinsics.<!DEPRECATION!>coroutineContext<!>
|
||||
kotlin.coroutines.experimental.coroutineContext
|
||||
coroutineContext
|
||||
}
|
||||
|
||||
suspend fun severalArgs(s: String, a: Any) {
|
||||
kotlin.coroutines.experimental.intrinsics.<!DEPRECATION!>coroutineContext<!>
|
||||
kotlin.coroutines.experimental.coroutineContext
|
||||
coroutineContext
|
||||
}
|
||||
}
|
||||
@@ -36,8 +48,16 @@ fun builderSeveralArgs(c: (Int, Int, Int) -> CoroutineContext) = {}
|
||||
fun builderSuspendSeveralArgs(c: suspend (Int, Int, Int) -> CoroutineContext) = {}
|
||||
|
||||
fun test() {
|
||||
builder { kotlin.coroutines.experimental.intrinsics.<!DEPRECATION, ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!> }
|
||||
builder { kotlin.coroutines.experimental.<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!> }
|
||||
builder { <!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!> }
|
||||
builderSuspend { kotlin.coroutines.experimental.intrinsics.<!DEPRECATION!>coroutineContext<!> }
|
||||
builderSuspend { kotlin.coroutines.experimental.coroutineContext }
|
||||
builderSuspend { coroutineContext }
|
||||
builderSeveralArgs {_, _,_ -> kotlin.coroutines.experimental.intrinsics.<!DEPRECATION, ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!> }
|
||||
builderSeveralArgs {_, _,_ -> kotlin.coroutines.experimental.<!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!> }
|
||||
builderSeveralArgs {_, _,_ -> <!ILLEGAL_SUSPEND_PROPERTY_ACCESS!>coroutineContext<!> }
|
||||
builderSuspendSeveralArgs {_, _,_ -> kotlin.coroutines.experimental.intrinsics.<!DEPRECATION!>coroutineContext<!>}
|
||||
builderSuspendSeveralArgs {_, _,_ -> kotlin.coroutines.experimental.coroutineContext}
|
||||
builderSuspendSeveralArgs {_, _,_ -> coroutineContext}
|
||||
}
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package
|
||||
|
||||
public fun builder(/*0*/ c: () -> kotlin.coroutines.experimental.CoroutineContext): () -> kotlin.Unit
|
||||
public fun builderSeveralArgs(/*0*/ c: (kotlin.Int, kotlin.Int, kotlin.Int) -> kotlin.coroutines.experimental.CoroutineContext): () -> kotlin.Unit
|
||||
public fun builderSuspend(/*0*/ c: suspend () -> kotlin.coroutines.experimental.CoroutineContext): () -> kotlin.Unit
|
||||
public fun builderSuspendSeveralArgs(/*0*/ c: suspend (kotlin.Int, kotlin.Int, kotlin.Int) -> kotlin.coroutines.experimental.CoroutineContext): () -> kotlin.Unit
|
||||
public suspend fun named(): kotlin.Unit
|
||||
public fun ordinal(): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val coroutineContext: kotlin.coroutines.experimental.CoroutineContext
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Controller {
|
||||
public constructor Controller()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final suspend fun named(): kotlin.Unit
|
||||
public final fun ordinal(): kotlin.Unit
|
||||
public final suspend fun severalArgs(/*0*/ s: kotlin.String, /*1*/ a: kotlin.Any): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -50,6 +50,7 @@ public class DescriptorUtils {
|
||||
private static final FqName VOLATILE = new FqName("kotlin.jvm.Volatile");
|
||||
private static final FqName SYNCHRONIZED = new FqName("kotlin.jvm.Synchronized");
|
||||
public static final FqName COROUTINES_PACKAGE_FQ_NAME = new FqName("kotlin.coroutines.experimental");
|
||||
public static final FqName COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"));
|
||||
public static final FqName CONTINUATION_INTERFACE_FQ_NAME = COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("Continuation"));
|
||||
|
||||
private DescriptorUtils() {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
suspend fun foo() {
|
||||
corou<caret>
|
||||
}
|
||||
|
||||
// EXIST: {"lookupString":"coroutineContext","tailText":" (kotlin.coroutines.experimental)","typeText":"CoroutineContext","attributes":"","allLookupStrings":"coroutineContext, getCoroutineContext","itemText":"coroutineContext"}
|
||||
// ABSENT: {"lookupString":"coroutineContext","tailText":" (kotlin.coroutines.experimental.intrinsics)","typeText":"CoroutineContext","attributes":"","allLookupStrings":"coroutineContext, getCoroutineContext","itemText":"coroutineContext"}
|
||||
+6
@@ -93,6 +93,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("CoroutineContext.kt")
|
||||
public void testCoroutineContext() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/CoroutineContext.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DataClassMembers.kt")
|
||||
public void testDataClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/DataClassMembers.kt");
|
||||
|
||||
+6
@@ -93,6 +93,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("CoroutineContext.kt")
|
||||
public void testCoroutineContext() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/CoroutineContext.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DataClassMembers.kt")
|
||||
public void testDataClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/DataClassMembers.kt");
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.js.translate.utils
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.backend.common.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -166,7 +165,7 @@ fun JsFunction.fillCoroutineMetadata(
|
||||
descriptor: FunctionDescriptor,
|
||||
hasController: Boolean
|
||||
) {
|
||||
val suspendPropertyDescriptor = context.currentModule.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME)
|
||||
val suspendPropertyDescriptor = context.currentModule.getPackage(DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME)
|
||||
.memberScope
|
||||
.getContributedVariables(COROUTINE_SUSPENDED_NAME, NoLookupLocation.FROM_BACKEND).first()
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
package kotlin.coroutines.experimental
|
||||
|
||||
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
|
||||
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
|
||||
import kotlin.coroutines.experimental.intrinsics.createCoroutineUnchecked
|
||||
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
|
||||
import kotlin.internal.InlineOnly
|
||||
|
||||
/**
|
||||
* Starts coroutine with receiver type [R] and result type [T].
|
||||
@@ -86,13 +87,29 @@ public fun <T> (suspend () -> T).createCoroutine(
|
||||
* from a different thread of execution. Repeated invocation of any resume function produces [IllegalStateException].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline suspend fun <T> suspendCoroutine(crossinline block: (Continuation<T>) -> Unit): T =
|
||||
public suspend inline fun <T> suspendCoroutine(crossinline block: (Continuation<T>) -> Unit): T =
|
||||
suspendCoroutineOrReturn { c: Continuation<T> ->
|
||||
val safe = SafeContinuation(c)
|
||||
block(safe)
|
||||
safe.getResult()
|
||||
}
|
||||
|
||||
/**
|
||||
* Continuation context of current coroutine.
|
||||
*
|
||||
* This allows the user code to not pass an extra [CoroutineContext] parameter in basic coroutine builders
|
||||
* like [launch](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/launch.html)
|
||||
* and [async](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/async.html),
|
||||
* but still provide easy access to coroutine context.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@Suppress("WRONG_MODIFIER_TARGET")
|
||||
@InlineOnly
|
||||
public suspend inline val coroutineContext: CoroutineContext
|
||||
get() {
|
||||
throw NotImplementedError("Implemented as intrinsic")
|
||||
}
|
||||
|
||||
// INTERNAL DECLARATIONS
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
|
||||
@@ -40,7 +40,7 @@ import kotlin.coroutines.experimental.*
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
public inline suspend fun <T> suspendCoroutineOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
|
||||
public suspend inline fun <T> suspendCoroutineOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
|
||||
suspendCoroutineUninterceptedOrReturn { cont -> block(cont.intercepted()) }
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public inline suspend fun <T> suspendCoroutineOrReturn(crossinline block: (Conti
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline suspend fun <T> suspendCoroutineUninterceptedOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
|
||||
public suspend inline fun <T> suspendCoroutineUninterceptedOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
|
||||
throw NotImplementedError("Implementation of suspendCoroutineUninterceptedOrReturn is intrinsic")
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,12 @@ public inline fun <T> Continuation<T>.intercepted(): Continuation<T> =
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@Suppress("WRONG_MODIFIER_TARGET")
|
||||
public inline suspend val coroutineContext: CoroutineContext
|
||||
@Deprecated(
|
||||
"Use kotlin.coroutines.experimental.coroutineContext instead",
|
||||
ReplaceWith("kotlin.coroutines.experimental.coroutineContext"),
|
||||
DeprecationLevel.WARNING
|
||||
)
|
||||
public suspend inline val coroutineContext: CoroutineContext
|
||||
get() {
|
||||
throw NotImplementedError("Implemented as intrinsic")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user