JVM IR: Make receiver type of IrGetField not null

otherwise, it will be mapped to inline class type if underlying type
is primitive of nullable.

 #KT-52913 Fixed
This commit is contained in:
Ilmir Usmanov
2022-06-27 03:13:33 +02:00
committed by Space
parent cb1a8bd687
commit a5084c2f69
10 changed files with 78 additions and 2 deletions
@@ -388,9 +388,12 @@ private class JvmInlineClassLowering(context: JvmBackendContext) : JvmValueClass
if (field.origin == IrDeclarationOrigin.PROPERTY_BACKING_FIELD &&
parent is IrClass &&
parent.isSingleFieldValueClass &&
field.name == parent.inlineClassFieldName) {
field.name == parent.inlineClassFieldName
) {
val receiver = expression.receiver!!.transform(this, null)
return coerceInlineClasses(receiver, receiver.type, field.type)
// If we get the field of nullable variable, we can be sure, that type is not null,
// since we first generate null check.
return coerceInlineClasses(receiver, receiver.type.makeNotNull(), field.type)
}
return super.visitGetField(expression)
}