Skip to content

Conversation

Godin
Copy link
Member

@Godin Godin commented Feb 9, 2020

For Example.kt

suspend fun example() {
   suspendingFunction()
}

suspend fun suspendingFunction() {
}

kotlinc version 1.3.31 generates

  public static final java.lang.Object example(kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #12                 // Method suspendingFunction:(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
         4: areturn
      LineNumberTable:
        line 2: 0

whereas starting from version 1.3.60 (see change JetBrains/kotlin@cc06798) generates

  public static final java.lang.Object example(kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
    Code:
      stack=3, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #12                 // Method suspendingFunction:(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
         4: dup
         5: invokestatic  #18                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
         8: if_acmpne     12
        11: areturn
        12: pop
        13: getstatic     #24                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
        16: areturn
      LineNumberTable:
        line 2: 0
        line 3: 13

@Godin Godin added this to the 0.8.6 milestone Feb 9, 2020
@Godin Godin marked this pull request as ready for review February 9, 2020 03:24
@Godin Godin requested a review from marchof February 9, 2020 03:24
@marchof marchof merged commit 71f9341 into master Feb 9, 2020
@marchof marchof deleted the kotlin_suspending_tail_call branch February 9, 2020 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants