Do not attempt to get field initializer if it is not available.
This may happen on Native if the property is in another module. #KT-62522 Fixed Related to: KT-62523
This commit is contained in:
committed by
Space Team
parent
9c1fa93607
commit
dcfc20f1ff
+4
-3
@@ -238,12 +238,13 @@ abstract class BaseIrGenerator(private val currentClass: IrClass, final override
|
||||
// check for call to .shouldEncodeElementDefault
|
||||
val encodeDefaults = property.ir.getEncodeDefaultAnnotationValue()
|
||||
val field =
|
||||
property.ir.backingField // Nullable when property from another module; can't compare it with default value on JS or Native
|
||||
if (!property.optional || encodeDefaults == true || field == null) {
|
||||
property.ir.backingField
|
||||
val initializer = field?.initializer // FIXME: Null when property from another module; can't compare it with default value on JS or Native
|
||||
if (!property.optional || encodeDefaults == true || field == null || initializer == null) {
|
||||
// emit call right away
|
||||
+elementCall
|
||||
} else {
|
||||
val partB = irNotEquals(property.irGet(), initializerAdapter(field.initializer!!))
|
||||
val partB = irNotEquals(property.irGet(), initializerAdapter(initializer))
|
||||
|
||||
val condition = if (encodeDefaults == false) {
|
||||
// drop default without call to .shouldEncodeElementDefault
|
||||
|
||||
Reference in New Issue
Block a user