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.
This commit is contained in:
@@ -141,7 +141,8 @@ internal val localDeclarationsPhase = makeIrFilePhase(
|
||||
|
||||
private fun scopedVisibility(inInlineFunctionScope: Boolean): DescriptorVisibility =
|
||||
if (inInlineFunctionScope) DescriptorVisibilities.PUBLIC else JavaDescriptorVisibilities.PACKAGE_VISIBILITY
|
||||
}
|
||||
},
|
||||
forceFieldsForInlineCaptures = true
|
||||
)
|
||||
},
|
||||
name = "JvmLocalDeclarations",
|
||||
|
||||
Reference in New Issue
Block a user