Files
kotlin-fork/compiler/testData/codegen/bytecodeText/fieldsForCapturedValues/constructorOnly.kt
T
pyos e1520c61da IR: use parameters for captures in field/instance initializers
val y = 1
    object { val x = y }
  ->
    class XKt$1(`$y`: Int) { val x: Int = `$y` }

Note that `$y` is not stored in a field because it's not used outside
the primary constructor.

One exception is captured inline parameters on the JVM backend, as the
bytecode inliner uses field assignment instructions (setfield) to locate
them; removing the field is thus not possible.
2021-09-29 16:25:43 +02:00

15 lines
303 B
Kotlin
Vendored

open class Base(parameter: String)
fun foo(captured: String) {
object : Base(captured) {
val x = captured
init { println(captured) }
}
}
// JVM_TEMPLATES
// 1 final synthetic Ljava/lang/String; \$captured
// JVM_IR_TEMPLATES
// 0 final synthetic Ljava/lang/String; \$captured