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

Update filter for Kotlin 1.5 suspending functions #1174

Merged
merged 3 commits into from Apr 13, 2021
Merged

Conversation

Godin
Copy link
Member

@Godin Godin commented Apr 12, 2021

Currently execution of

mvn clean package -Dkotlin.version=1.5.0-M2

leads to

Failed tests:
  all_missed_instructions_should_have_line_number(org.jacoco.core.test.validation.kotlin.KotlinCoroutineTest): sum of missed instructions of all lines should be equal to missed instructions of file expected:<4> but was:<2>

For the following Example.kt

private suspend fun example() {
    println("private")
}

Execution of

kotlin/bin/kotlinc Example.kt -d classes
javap -v -p classes/ExampleKt.class

using Kotlin compiler version 1.4 produces

{
  static final java.lang.Object example(kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: (0x1018) ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC
    Code:
      stack=2, locals=3, args_size=1
         0: ldc           #9                  // String private
         2: astore_1
         3: iconst_0
         4: istore_2
         5: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
         8: aload_1
         9: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
        12: getstatic     #27                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
        15: areturn
      LineNumberTable:
        line 2: 0
        line 3: 12
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      16     0 $completion   Lkotlin/coroutines/Continuation;
    Signature: #7                           // (Lkotlin/coroutines/Continuation<-Lkotlin/Unit;>;)Ljava/lang/Object;
}

whereas using Kotlin compiler version 1.5-M2 produces

{
  private static final java.lang.Object example(kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: (0x001a) ACC_PRIVATE, ACC_STATIC, ACC_FINAL
    Code:
      stack=2, locals=3, args_size=1
         0: ldc           #9                  // String private
         2: astore_1
         3: iconst_0
         4: istore_2
         5: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
         8: aload_1
         9: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
        12: getstatic     #27                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
        15: areturn
      LineNumberTable:
        line 2: 0
        line 3: 12
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      16     0 $completion   Lkotlin/coroutines/Continuation;
    Signature: #7                           // (Lkotlin/coroutines/Continuation<-Lkotlin/Unit;>;)Ljava/lang/Object;

  public static final java.lang.Object access$example(kotlin.coroutines.Continuation);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: (0x1019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #32                 // Method example:(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
         4: areturn
      LineNumberTable:
        line 1: 1
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0 $completion   Lkotlin/coroutines/Continuation;
}

This seems to be related to the following change in Kotlin compiler -
JetBrains/kotlin@85b9b5b

@Godin Godin added this to the 0.8.7 milestone Apr 12, 2021
@Godin Godin self-assigned this Apr 12, 2021
@Godin Godin added this to To Do in Filtering via automation Apr 12, 2021
@Godin Godin added this to Implementation in Current work items via automation Apr 12, 2021
@Godin Godin moved this from To Do to In Progress in Filtering Apr 12, 2021
@Godin Godin changed the title (WIP) add unit test Update filter for Kotlin 1.5 suspending functions Apr 12, 2021
@Godin Godin moved this from Implementation to Review in Current work items Apr 12, 2021
@Godin Godin marked this pull request as ready for review April 12, 2021 22:23
@Godin Godin requested a review from marchof April 12, 2021 22:24
@marchof marchof merged commit 86dc5fd into master Apr 13, 2021
Filtering automation moved this from In Progress to Done Apr 13, 2021
Current work items automation moved this from Review to Done Apr 13, 2021
@marchof marchof deleted the kotlin_suspend branch April 13, 2021 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Filtering
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants