Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synthetic methods that represent Kotlin suspend functions should not be ignored #804

Merged
merged 7 commits into from
Dec 27, 2018

Conversation

Godin
Copy link
Member

@Godin Godin commented Dec 24, 2018

Seems that Kotlin compiler generates synthetic methods for private and open suspending functions:

Example.kt

import kotlinx.coroutines.delay

private suspend fun suspendingFunction(x: Long) {
    delay(x) // line 4
}

open class Open {
    open suspend fun suspendingFunction(x: Long) {
        delay(x) // line 9
    }
}

javap -v -p ExampleKt.class

  static final java.lang.Object suspendingFunction(long, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC
    Code:
      stack=3, locals=3, args_size=2
         0: lload_0
         1: aload_2
         2: invokestatic  #13                 // Method kotlinx/coroutines/DelayKt.delay:(JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
         5: areturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0     x   J
      LineNumberTable:
        line 4: 0

javap -v -p Open.class

  public java.lang.Object suspendingFunction(long, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_PUBLIC
    Code:
      stack=4, locals=4, args_size=3
         0: aload_0
         1: lload_1
         2: aload_3
         3: invokestatic  #12                 // Method suspendingFunction$suspendImpl:(LOpen;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
         6: areturn

  static java.lang.Object suspendingFunction$suspendImpl(Open, long, kotlin.coroutines.Continuation);
    descriptor: (LOpen;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=3, locals=4, args_size=3
         0: lload_1
         1: aload_3
         2: invokestatic  #17                 // Method kotlinx/coroutines/DelayKt.delay:(JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
         5: areturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   LOpen;
            0       6     1     x   J
      LineNumberTable:
        line 9: 0

@Godin Godin self-assigned this Dec 23, 2018
@Godin Godin added this to To Do in Filtering via automation Dec 23, 2018
@Godin Godin added this to Candidates in Current work items via automation Dec 23, 2018
@Godin Godin moved this from Candidates to Implementation in Current work items Dec 24, 2018
@Godin Godin changed the title Report code coverage correctly for Kotlin private suspending functions synthetic methods that represent Kotlin suspend functions should not be ignored Dec 26, 2018
@Godin Godin moved this from Implementation to Review in Current work items Dec 26, 2018
@Godin Godin requested a review from marchof December 26, 2018 22:42
@Godin Godin added this to the 0.8.3 milestone Dec 26, 2018
Copy link
Member

@marchof marchof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Godin Thx!

@marchof marchof merged commit fd90e3e into master Dec 27, 2018
Filtering automation moved this from To Do to Done Dec 27, 2018
Current work items automation moved this from Review to Done Dec 27, 2018
@marchof marchof deleted the kotlin_suspend_function branch December 27, 2018 23:11
@jacoco jacoco locked as resolved and limited conversation to collaborators May 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Filtering
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants