Generate state-machine even if the object is going to be transformed
This fixes Java interop of inline functions, which use coroutines. However, we cannot transform the state-machine. Thus, we generate a $$forInline counterpart for suspend functions (similar to inline suspend functions) and invokeSuspend$$forInline for lambdas if these coroutines are going to transformed (i.e. are declared inside inline functions). During transformation we just skip method with state-machine and transform the $$forInline counterpart. Of course, if inline site is inline itself, we generate both state-machine version (which will be dropped during the next transformation) and $$forInline version. Consequently, the final version of the coroutines will not have $$forInline counterpart. Unfortunately, since CompileKotlinAgainstInlineKotlin tests do not allow java sources, the tests for the interop are usual box tests. #KT-30707 Fixed
This commit is contained in:
@@ -6,5 +6,8 @@ inline fun inlineMe(crossinline c: suspend () -> Int): suspend () -> Int {
|
||||
return i
|
||||
}
|
||||
|
||||
// invokeSuspend$$forInline : valueOf
|
||||
// invokeSuspend : boxInt
|
||||
|
||||
// 1 valueOf
|
||||
// 0 boxInt
|
||||
// 1 boxInt
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ fun main(args: Array<String>) {
|
||||
@BuilderInference
|
||||
suspend fun SequenceScope<Int>.awaitSeq(): Int = 42
|
||||
|
||||
// 1 LOCALVARIABLE a I L16 L.* 3
|
||||
// 1 LINENUMBER 8 L16
|
||||
// 1 LOCALVARIABLE a I L17 L.* 3
|
||||
// 1 LINENUMBER 8 L17
|
||||
// Adding ignore flags below the test since the test relies on line numbers.
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
|
||||
+3
-1
@@ -21,4 +21,6 @@ class Test {
|
||||
}
|
||||
}
|
||||
|
||||
// 4 TABLESWITCH
|
||||
// suspend lambdas: 4
|
||||
// suspend lambdas $$forInline: 1
|
||||
// 5 TABLESWITCH
|
||||
Reference in New Issue
Block a user