Introduce startCoroutineUninterceptedOrReturn coroutine intrinsic
#KT-15716 Fixed
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
|
import kotlin.coroutines.experimental.*
|
||||||
|
import kotlin.coroutines.experimental.intrinsics.*
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
||||||
|
x.resume("OK")
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun suspendWithException(): String = suspendCoroutineOrReturn { x ->
|
||||||
|
x.resumeWithException(RuntimeException("OK"))
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> String): String {
|
||||||
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
|
c.startCoroutine(object: Continuation<String> {
|
||||||
|
override val context: CoroutineContext
|
||||||
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
|
override fun resumeWithException(exception: Throwable) {
|
||||||
|
fromSuspension = "Exception: " + exception.message!!
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resume(value: String) {
|
||||||
|
fromSuspension = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return fromSuspension as String
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (builder { "OK" } != "OK") return "fail 4"
|
||||||
|
if (builder { suspendHere() } != "OK") return "fail 5"
|
||||||
|
|
||||||
|
if (builder { throw RuntimeException("OK") } != "Exception: OK") return "fail 6"
|
||||||
|
if (builder { suspendWithException() } != "Exception: OK") return "fail 7"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Vendored
+55
@@ -0,0 +1,55 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
|
import kotlin.coroutines.experimental.*
|
||||||
|
import kotlin.coroutines.experimental.intrinsics.*
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
||||||
|
x.resume("OK")
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun suspendWithException(): String = suspendCoroutineOrReturn { x ->
|
||||||
|
x.resumeWithException(RuntimeException("OK"))
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(shouldSuspend: Boolean, c: suspend () -> String): String {
|
||||||
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
|
val result = try {
|
||||||
|
c.startCoroutineUninterceptedOrReturn(object: Continuation<String> {
|
||||||
|
override val context: CoroutineContext
|
||||||
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
|
override fun resumeWithException(exception: Throwable) {
|
||||||
|
fromSuspension = "Exception: " + exception.message!!
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resume(value: String) {
|
||||||
|
fromSuspension = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: Exception) {
|
||||||
|
"Exception: ${e.message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldSuspend) {
|
||||||
|
if (result !== COROUTINE_SUSPENDED) throw RuntimeException("fail 1")
|
||||||
|
if (fromSuspension == null) throw RuntimeException("fail 2")
|
||||||
|
return fromSuspension!!
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result === COROUTINE_SUSPENDED) throw RuntimeException("fail 3")
|
||||||
|
return result as String
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (builder(false) { "OK" } != "OK") return "fail 4"
|
||||||
|
if (builder(true) { suspendHere() } != "OK") return "fail 5"
|
||||||
|
|
||||||
|
if (builder(false) { throw RuntimeException("OK") } != "Exception: OK") return "fail 6"
|
||||||
|
if (builder(true) { suspendWithException() } != "Exception: OK") return "fail 7"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+80
@@ -0,0 +1,80 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
import kotlin.coroutines.experimental.*
|
||||||
|
import kotlin.coroutines.experimental.intrinsics.*
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
||||||
|
x.resume("OK")
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun suspendWithException(): String = suspendCoroutineOrReturn { x ->
|
||||||
|
x.resumeWithException(RuntimeException("OK"))
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(shouldSuspend: Boolean, expectedCount: Int, c: suspend () -> String): String {
|
||||||
|
var fromSuspension: String? = null
|
||||||
|
var counter = 0
|
||||||
|
|
||||||
|
val result = try {
|
||||||
|
c.startCoroutineUninterceptedOrReturn(object: Continuation<String> {
|
||||||
|
override val context: CoroutineContext
|
||||||
|
get() = ContinuationDispatcher { counter++ }
|
||||||
|
|
||||||
|
override fun resumeWithException(exception: Throwable) {
|
||||||
|
fromSuspension = "Exception: " + exception.message!!
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resume(value: String) {
|
||||||
|
fromSuspension = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: Exception) {
|
||||||
|
"Exception: ${e.message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (counter != expectedCount) throw RuntimeException("fail 0")
|
||||||
|
|
||||||
|
if (shouldSuspend) {
|
||||||
|
if (result !== COROUTINE_SUSPENDED) throw RuntimeException("fail 1")
|
||||||
|
if (fromSuspension == null) throw RuntimeException("fail 2")
|
||||||
|
return fromSuspension!!
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result === COROUTINE_SUSPENDED) throw RuntimeException("fail 3")
|
||||||
|
return result as String
|
||||||
|
}
|
||||||
|
|
||||||
|
class ContinuationDispatcher(val dispatcher: () -> Unit) : AbstractCoroutineContextElement(ContinuationInterceptor), ContinuationInterceptor {
|
||||||
|
override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> = DispatchedContinuation(dispatcher, continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DispatchedContinuation<T>(
|
||||||
|
val dispatcher: () -> Unit,
|
||||||
|
val continuation: Continuation<T>
|
||||||
|
): Continuation<T> {
|
||||||
|
override val context: CoroutineContext = continuation.context
|
||||||
|
|
||||||
|
override fun resume(value: T) {
|
||||||
|
dispatcher()
|
||||||
|
continuation.resume(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resumeWithException(exception: Throwable) {
|
||||||
|
dispatcher()
|
||||||
|
continuation.resumeWithException(exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (builder(false, 0) { "OK" } != "OK") return "fail 4"
|
||||||
|
if (builder(true, 1) { suspendHere() } != "OK") return "fail 5"
|
||||||
|
|
||||||
|
if (builder(false, 0) { throw RuntimeException("OK") } != "Exception: OK") return "fail 6"
|
||||||
|
if (builder(true, 1) { suspendWithException() } != "Exception: OK") return "fail 7"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class CoroutineUtilKt {
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method handleExceptionContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): kotlin.coroutines.experimental.Continuation
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method handleResultContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): kotlin.coroutines.experimental.Continuation
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public class EmptyContinuation {
|
||||||
|
public final static field Companion: EmptyContinuation.Companion
|
||||||
|
private final @org.jetbrains.annotations.NotNull field context: kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
inner class EmptyContinuation/Companion
|
||||||
|
public @synthetic.kotlin.jvm.GeneratedByJvmOverloads method <init>(): void
|
||||||
|
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.CoroutineContext): void
|
||||||
|
public synthetic method <init>(p0: kotlin.coroutines.experimental.CoroutineContext, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method getContext(): kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
public method resume(@org.jetbrains.annotations.Nullable p0: java.lang.Object): void
|
||||||
|
public method resumeWithException(@org.jetbrains.annotations.NotNull p0: java.lang.Throwable): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final static class EmptyContinuation/Companion {
|
||||||
|
inner class EmptyContinuation/Companion
|
||||||
|
private method <init>(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class StartCoroutineKt {
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): java.lang.String
|
||||||
|
public final static @org.jetbrains.annotations.Nullable method suspendHere(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
|
public final static @org.jetbrains.annotations.Nullable method suspendWithException(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class CoroutineUtilKt {
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method handleExceptionContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): kotlin.coroutines.experimental.Continuation
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method handleResultContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): kotlin.coroutines.experimental.Continuation
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public class EmptyContinuation {
|
||||||
|
public final static field Companion: EmptyContinuation.Companion
|
||||||
|
private final @org.jetbrains.annotations.NotNull field context: kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
inner class EmptyContinuation/Companion
|
||||||
|
public @synthetic.kotlin.jvm.GeneratedByJvmOverloads method <init>(): void
|
||||||
|
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.CoroutineContext): void
|
||||||
|
public synthetic method <init>(p0: kotlin.coroutines.experimental.CoroutineContext, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method getContext(): kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
public method resume(@org.jetbrains.annotations.Nullable p0: java.lang.Object): void
|
||||||
|
public method resumeWithException(@org.jetbrains.annotations.NotNull p0: java.lang.Throwable): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final static class EmptyContinuation/Companion {
|
||||||
|
inner class EmptyContinuation/Companion
|
||||||
|
private method <init>(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class StartCoroutineUninterceptedOrReturnKt {
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method builder(p0: boolean, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function1): java.lang.String
|
||||||
|
public final static @org.jetbrains.annotations.Nullable method suspendHere(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
|
public final static @org.jetbrains.annotations.Nullable method suspendWithException(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class ContinuationDispatcher {
|
||||||
|
private final @org.jetbrains.annotations.NotNull field dispatcher: kotlin.jvm.functions.Function0
|
||||||
|
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getDispatcher(): kotlin.jvm.functions.Function0
|
||||||
|
public @org.jetbrains.annotations.NotNull method interceptContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): kotlin.coroutines.experimental.Continuation
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class CoroutineUtilKt {
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method handleExceptionContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): kotlin.coroutines.experimental.Continuation
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method handleResultContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): kotlin.coroutines.experimental.Continuation
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
final class DispatchedContinuation {
|
||||||
|
private final @org.jetbrains.annotations.NotNull field context: kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
private final @org.jetbrains.annotations.NotNull field continuation: kotlin.coroutines.experimental.Continuation
|
||||||
|
private final @org.jetbrains.annotations.NotNull field dispatcher: kotlin.jvm.functions.Function0
|
||||||
|
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.experimental.Continuation): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method getContext(): kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getContinuation(): kotlin.coroutines.experimental.Continuation
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getDispatcher(): kotlin.jvm.functions.Function0
|
||||||
|
public method resume(p0: java.lang.Object): void
|
||||||
|
public method resumeWithException(@org.jetbrains.annotations.NotNull p0: java.lang.Throwable): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public class EmptyContinuation {
|
||||||
|
public final static field Companion: EmptyContinuation.Companion
|
||||||
|
private final @org.jetbrains.annotations.NotNull field context: kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
inner class EmptyContinuation/Companion
|
||||||
|
public @synthetic.kotlin.jvm.GeneratedByJvmOverloads method <init>(): void
|
||||||
|
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.CoroutineContext): void
|
||||||
|
public synthetic method <init>(p0: kotlin.coroutines.experimental.CoroutineContext, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method getContext(): kotlin.coroutines.experimental.CoroutineContext
|
||||||
|
public method resume(@org.jetbrains.annotations.Nullable p0: java.lang.Object): void
|
||||||
|
public method resumeWithException(@org.jetbrains.annotations.NotNull p0: java.lang.Throwable): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final static class EmptyContinuation/Companion {
|
||||||
|
inner class EmptyContinuation/Companion
|
||||||
|
private method <init>(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class StartCoroutineUninterceptedOrReturnInterceptionKt {
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||||
|
public final static @org.jetbrains.annotations.NotNull method builder(p0: boolean, p1: int, @org.jetbrains.annotations.NotNull p2: kotlin.jvm.functions.Function1): java.lang.String
|
||||||
|
public final static @org.jetbrains.annotations.Nullable method suspendHere(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
|
public final static @org.jetbrains.annotations.Nullable method suspendWithException(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): java.lang.Object
|
||||||
|
}
|
||||||
+27
@@ -5156,6 +5156,33 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class IntrinsicSemantics extends AbstractIrBlackBoxCodegenTest {
|
||||||
|
public void testAllFilesPresentInIntrinsicSemantics() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/intrinsicSemantics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutine.kt")
|
||||||
|
public void testStartCoroutine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutineUninterceptedOrReturn.kt")
|
||||||
|
public void testStartCoroutineUninterceptedOrReturn() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutineUninterceptedOrReturnInterception.kt")
|
||||||
|
public void testStartCoroutineUninterceptedOrReturnInterception() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/coroutines/multiModule")
|
@TestMetadata("compiler/testData/codegen/box/coroutines/multiModule")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -5156,6 +5156,33 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class IntrinsicSemantics extends AbstractBlackBoxCodegenTest {
|
||||||
|
public void testAllFilesPresentInIntrinsicSemantics() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/intrinsicSemantics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutine.kt")
|
||||||
|
public void testStartCoroutine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutineUninterceptedOrReturn.kt")
|
||||||
|
public void testStartCoroutineUninterceptedOrReturn() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutineUninterceptedOrReturnInterception.kt")
|
||||||
|
public void testStartCoroutineUninterceptedOrReturnInterception() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/coroutines/multiModule")
|
@TestMetadata("compiler/testData/codegen/box/coroutines/multiModule")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.coroutines.experimental.intrinsics
|
||||||
|
|
||||||
|
import kotlin.coroutines.experimental.Continuation
|
||||||
|
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn(
|
||||||
|
completion: Continuation<T>
|
||||||
|
): Any? = this.asDynamic()(completion, false)
|
||||||
|
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn(
|
||||||
|
receiver: R,
|
||||||
|
completion: Continuation<T>
|
||||||
|
): Any? = this.asDynamic()(receiver, completion, false)
|
||||||
+33
@@ -5847,6 +5847,39 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class IntrinsicSemantics extends AbstractJsCodegenBoxTest {
|
||||||
|
public void testAllFilesPresentInIntrinsicSemantics() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/intrinsicSemantics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutine.kt")
|
||||||
|
public void testStartCoroutine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutineUninterceptedOrReturn.kt")
|
||||||
|
public void testStartCoroutineUninterceptedOrReturn() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("startCoroutineUninterceptedOrReturnInterception.kt")
|
||||||
|
public void testStartCoroutineUninterceptedOrReturnInterception() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt");
|
||||||
|
try {
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
catch (Throwable ignore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/coroutines/multiModule")
|
@TestMetadata("compiler/testData/codegen/box/coroutines/multiModule")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:kotlin.jvm.JvmName("IntrinsicsJvmKt")
|
||||||
|
@file:kotlin.jvm.JvmVersion
|
||||||
|
package kotlin.coroutines.experimental.intrinsics
|
||||||
|
import kotlin.coroutines.experimental.*
|
||||||
|
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn(
|
||||||
|
completion: Continuation<T>
|
||||||
|
): Any? = (this as Function1<Continuation<T>, Any?>).invoke(completion)
|
||||||
|
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn(
|
||||||
|
receiver: R,
|
||||||
|
completion: Continuation<T>
|
||||||
|
): Any? = (this as Function2<R, Continuation<T>, Any?>).invoke(receiver, completion)
|
||||||
Reference in New Issue
Block a user