JVM_IR: partially fix inline methods using captured crossinline lambdas
The fields containing crossinline lambdas should be package-private to
avoid generating synthetic accessors, which break object regeneration.
Note that the inline methods cannot actually be called, as call sites
will attempt to read the captured lambda from a field through a *copy*
of the local containing the object, so these reads will not be inlined,
causing an exception at runtime:
inline fun f(crossinline g: () -> Unit) = object : I {
inline fun h() = g()
// effectively `val tmp = this; return tmp.$g()`:
override fun run() = h()
}
f {}.run() // NoSuchFieldError: $g
This particular example can be fixed by reusing locals for receiver
parameters in IrInlineCodegen, but explicitly assigning `this` to
another variable and calling an inline method on it will break it again.
(This is only applicable to the JVM_IR backend, as the non-IR one fails
to generate `f` at all for some other reason.)
This commit is contained in:
+2
-2
@@ -21,7 +21,7 @@ public final class TcoContinuationKt$collect$2$emit$1 {
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TcoContinuationKt$collect$2 {
|
||||
private synthetic final field $action: kotlin.jvm.functions.Function2
|
||||
synthetic final @org.jetbrains.annotations.NotNull field $action: kotlin.jvm.functions.Function2
|
||||
inner class TcoContinuationKt$collect$2
|
||||
inner class TcoContinuationKt$collect$2$emit$1
|
||||
public method <init>(p0: kotlin.jvm.functions.Function2): void
|
||||
@@ -42,7 +42,7 @@ public final class TcoContinuationKt$flow$1$collect$1 {
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TcoContinuationKt$flow$1 {
|
||||
private synthetic final field $block: kotlin.jvm.functions.Function2
|
||||
synthetic final @org.jetbrains.annotations.NotNull field $block: kotlin.jvm.functions.Function2
|
||||
inner class TcoContinuationKt$flow$1
|
||||
inner class TcoContinuationKt$flow$1$collect$1
|
||||
public method <init>(p0: kotlin.jvm.functions.Function2): void
|
||||
|
||||
Reference in New Issue
Block a user