JVM_IR: treat suspend-converted references as lambdas for inlining

Again, this is consistent with adapted function references, since
they're pretty much the same anyway.
This commit is contained in:
pyos
2020-10-06 17:06:11 +02:00
committed by max-kammerer
parent 12bec7cca2
commit a4b67f007f
14 changed files with 105 additions and 14 deletions
@@ -0,0 +1,21 @@
// !LANGUAGE: +SuspendConversion
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JVM, NATIVE
// IGNORE_LIGHT_ANALYSIS
// `lambda` should not be wrapped in yet another object (so no OnInlineArgumentKt$box$1$1).
// CHECK_BYTECODE_LISTING
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
inline suspend fun runS(fn: suspend (String) -> String) = fn("O")
fun box(): String {
var test = "Failed"
val lambda: (String) -> String = { it + "K" }
suspend { test = runS(lambda) }.startCoroutine(EmptyContinuation)
return test
}
@@ -0,0 +1,36 @@
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class OnInlineArgumentKt$box$1 {
// source: 'onInlineArgument.kt'
enclosing method OnInlineArgumentKt.box()Ljava/lang/String;
synthetic final field $lambda: kotlin.jvm.functions.Function1
synthetic final field $test: kotlin.jvm.internal.Ref$ObjectRef
field label: int
inner (anonymous) class OnInlineArgumentKt$box$1
method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.jvm.functions.Function1, p2: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
public final method invoke(p0: java.lang.Object): java.lang.Object
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
}
@kotlin.Metadata
final class OnInlineArgumentKt$box$lambda$1 {
// source: 'onInlineArgument.kt'
enclosing method OnInlineArgumentKt.box()Ljava/lang/String;
public final static field INSTANCE: OnInlineArgumentKt$box$lambda$1
inner (anonymous) class OnInlineArgumentKt$box$lambda$1
static method <clinit>(): void
method <init>(): void
public final @org.jetbrains.annotations.NotNull method invoke(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public synthetic bridge method invoke(p0: java.lang.Object): java.lang.Object
}
@kotlin.Metadata
public final class OnInlineArgumentKt {
// source: 'onInlineArgument.kt'
inner (anonymous) class OnInlineArgumentKt$box$1
inner (anonymous) class OnInlineArgumentKt$box$lambda$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
private final static method runS$$forInline(p0: kotlin.jvm.functions.Function2, p1: kotlin.coroutines.Continuation): java.lang.Object
public final static @org.jetbrains.annotations.Nullable method runS(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function2, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
}