JVM IR: Fix inline class constructors taking default values of inline class type.

This commit is contained in:
Steven Schäfer
2020-02-18 14:53:21 +01:00
committed by Alexander Udalov
parent 846e50a0c0
commit 4ac45eb38b
8 changed files with 43 additions and 0 deletions
@@ -430,6 +430,8 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
origin = JvmLoweredDeclarationOrigin.SYNTHETIC_INLINE_CLASS_MEMBER
returnType = irConstructor.returnType
}.apply {
// Don't create a default argument stub for the primary constructor
irConstructor.valueParameters.forEach { it.defaultValue = null }
copyParameterDeclarationsFrom(irConstructor)
body = context.createIrBuilder(this.symbol).irBlockBody(this) {
+irDelegatingConstructorCall(context.irBuiltIns.anyClass.owner.constructors.single())
@@ -444,6 +446,7 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
// Add a static bridge method to the primary constructor.
// This is a placeholder for null-checks and default arguments.
val function = context.inlineClassReplacements.getReplacementFunction(irConstructor)!!
function.valueParameters.forEach { it.transformChildrenVoid() }
with(context.createIrBuilder(function.symbol)) {
val argument = function.valueParameters[0]
function.body = irExprBody(