Move coroutineContext to correct package

from kotlin.coroutines.experimental.instrinsics to kotlin.coroutines.experimental

 #KT-22400
This commit is contained in:
Ilmir Usmanov
2018-01-23 20:35:50 +03:00
parent efabf80d37
commit 18c03f94f8
17 changed files with 247 additions and 86 deletions
@@ -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"
}
@@ -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"
}
@@ -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