Reflection: do not try to box COROUTINE_SUSPENDED
#KT-58887 Fixed
This commit is contained in:
committed by
Space Team
parent
bd6af5cc42
commit
a58a1a3398
+6
@@ -44311,6 +44311,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt58887.kt")
|
||||||
|
public void testKt58887() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("primaryValOfInlineClass.kt")
|
@TestMetadata("primaryValOfInlineClass.kt")
|
||||||
public void testPrimaryValOfInlineClass() throws Exception {
|
public void testPrimaryValOfInlineClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -44311,6 +44311,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt58887.kt")
|
||||||
|
public void testKt58887() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("primaryValOfInlineClass.kt")
|
@TestMetadata("primaryValOfInlineClass.kt")
|
||||||
public void testPrimaryValOfInlineClass() throws Exception {
|
public void testPrimaryValOfInlineClass() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_REFLECT
|
||||||
|
// WITH_COROUTINES
|
||||||
|
|
||||||
|
import helpers.EmptyContinuation
|
||||||
|
import kotlin.coroutines.Continuation
|
||||||
|
import kotlin.coroutines.startCoroutine
|
||||||
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
import kotlin.reflect.KFunction
|
||||||
|
import kotlin.reflect.full.callSuspendBy
|
||||||
|
|
||||||
|
var c: Continuation<Z>? = null
|
||||||
|
|
||||||
|
suspend fun suspendMe(): Z =
|
||||||
|
suspendCoroutine { c = it }
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(EmptyContinuation())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var result = Z("Fail")
|
||||||
|
builder {
|
||||||
|
val ref: KFunction<Z> = ::suspendMe
|
||||||
|
result = ref.callSuspendBy(emptyMap())
|
||||||
|
}
|
||||||
|
c!!.resumeWith(Result.success(Z("OK")))
|
||||||
|
return result.value
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmInline
|
||||||
|
value class Z(val value: String) {
|
||||||
|
override fun toString(): String = value
|
||||||
|
}
|
||||||
+6
@@ -41701,6 +41701,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt58887.kt")
|
||||||
|
public void testKt58887() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("primaryValOfInlineClass.kt")
|
@TestMetadata("primaryValOfInlineClass.kt")
|
||||||
public void testPrimaryValOfInlineClass() throws Exception {
|
public void testPrimaryValOfInlineClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -44311,6 +44311,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt58887.kt")
|
||||||
|
public void testKt58887() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("primaryValOfInlineClass.kt")
|
@TestMetadata("primaryValOfInlineClass.kt")
|
||||||
public void testPrimaryValOfInlineClass() throws Exception {
|
public void testPrimaryValOfInlineClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -44311,6 +44311,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt58887.kt")
|
||||||
|
public void testKt58887() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("primaryValOfInlineClass.kt")
|
@TestMetadata("primaryValOfInlineClass.kt")
|
||||||
public void testPrimaryValOfInlineClass() throws Exception {
|
public void testPrimaryValOfInlineClass() throws Exception {
|
||||||
|
|||||||
+5
@@ -35138,6 +35138,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt58887.kt")
|
||||||
|
public void testKt58887() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/kt58887.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("primaryValOfInlineClass.kt")
|
@TestMetadata("primaryValOfInlineClass.kt")
|
||||||
public void testPrimaryValOfInlineClass() throws Exception {
|
public void testPrimaryValOfInlineClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.types.asSimpleType
|
|||||||
import java.lang.reflect.Member
|
import java.lang.reflect.Member
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import java.lang.reflect.Type
|
import java.lang.reflect.Type
|
||||||
|
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
|
||||||
import kotlin.reflect.jvm.internal.KDeclarationContainerImpl
|
import kotlin.reflect.jvm.internal.KDeclarationContainerImpl
|
||||||
import kotlin.reflect.jvm.internal.KotlinReflectionInternalError
|
import kotlin.reflect.jvm.internal.KotlinReflectionInternalError
|
||||||
import kotlin.reflect.jvm.internal.defaultPrimitiveValue
|
import kotlin.reflect.jvm.internal.defaultPrimitiveValue
|
||||||
@@ -186,6 +187,7 @@ internal class ValueClassAwareCaller<out M : Member?>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val result = caller.call(unboxedArguments)
|
val result = caller.call(unboxedArguments)
|
||||||
|
if (result === COROUTINE_SUSPENDED) return result
|
||||||
|
|
||||||
// box is not null only for inline classes
|
// box is not null only for inline classes
|
||||||
return box?.invoke(null, result) ?: result
|
return box?.invoke(null, result) ?: result
|
||||||
|
|||||||
Reference in New Issue
Block a user