Skip to content

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 changed the title (WIP) add unit test Update filter for Kotlin 1.5 suspending functions 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
@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
Archived in project
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants