Skip to content

Conversation

Godin
Copy link
Member

@Godin Godin commented Apr 4, 2025

inline value class

Given src/Utils.kt

suspend fun suspendingFunction(): String = ""
suspend fun suspendingFunctionReturningInlineValueClass(): InlineValueClass = InlineValueClass("")
@JvmInline
value class InlineValueClass(val value: String)
fun beforeSuspensionPoint() = Any()
fun afterSuspensionPoint(a: Any, b: Any) = Unit

compilation of src/Example.kt

import kotlinx.coroutines.runBlocking

fun example() =
    runBlocking {
        afterSuspensionPoint(
            beforeSuspensionPoint(),
            suspendingFunction()
        )
    }

differs from compilation of src/Example.kt

import kotlinx.coroutines.runBlocking

fun example() =
    runBlocking {
        afterSuspensionPoint(
            beforeSuspensionPoint(),
            suspendingFunctionReturningInlineValueClass()
        )
    }

as

index 274d343..1df493e 100644
--- 1/1.txt
+++ 2/2.txt
@@ -66,7 +66,7 @@ final class ExampleKt$example$1 extends kotlin/coroutines/jvm/internal/SuspendLa
     ALOAD 0
     ICONST_1
     PUTFIELD ExampleKt$example$1.label : I
-    INVOKESTATIC UtilsKt.suspendingFunctionReturningInlineValueClass (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+    INVOKESTATIC UtilsKt.suspendingFunction (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     DUP
     ALOAD 3
     IF_ACMPNE L7
@@ -82,15 +82,10 @@ final class ExampleKt$example$1 extends kotlin/coroutines/jvm/internal/SuspendLa
     ALOAD 1
     INVOKESTATIC kotlin/ResultKt.throwOnFailure (Ljava/lang/Object;)V
     ALOAD 1
-    CHECKCAST InlineValueClass
-    INVOKEVIRTUAL InlineValueClass.unbox-impl ()Ljava/lang/String;
    L7
-    LINENUMBER 7 L7
    FRAME FULL [ExampleKt$example$1 java/lang/Object java/lang/Object java/lang/Object] [java/lang/Object]
     ALOAD 2
     SWAP
-    CHECKCAST java/lang/String
-    INVOKESTATIC InlineValueClass.box-impl (Ljava/lang/String;)LInlineValueClass;
    L9
     LINENUMBER 5 L9
     INVOKESTATIC UtilsKt.afterSuspensionPoint (Ljava/lang/Object;Ljava/lang/Object;)V

and

nextIs(Opcodes.ALOAD);
nextIsThrowOnFailure();
nextIs(Opcodes.ALOAD);
if (cursor != null && skipNonOpcodes(cursor
.getNext()) == continuationAfterLoadedResult) {

does not handle

    CHECKCAST InlineValueClass
    INVOKEVIRTUAL InlineValueClass.unbox-impl ()Ljava/lang/String;

JetBrains/kotlin@ccc5b7a


See #1868 (comment) and #1868 (comment)

@Godin Godin self-assigned this Apr 4, 2025
@Godin Godin added this to Filtering Apr 4, 2025
@github-project-automation github-project-automation bot moved this to Awaiting triage in Filtering Apr 4, 2025
@Godin Godin moved this from Awaiting triage to In Progress in Filtering Apr 4, 2025
@Godin Godin added this to the 0.8.14 milestone Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant