[KLIB] Deserialize backing field initializers of const in IB-only mode
Missing const initializer leads to crash in property accessors inline lowering during IC recompilation on JS. - fix #KT-50512 - add test for JS IR IC
This commit is contained in:
+6
-6
@@ -456,11 +456,11 @@ class IrDeclarationDeserializer(
|
||||
}
|
||||
|
||||
|
||||
private fun IrField.withInitializerGuard(f: IrField.() -> Unit) {
|
||||
private fun IrField.withInitializerGuard(isConst: Boolean, f: IrField.() -> Unit) {
|
||||
val oldBodiesPolicy = deserializeBodies
|
||||
|
||||
try {
|
||||
deserializeBodies = oldBodiesPolicy || type.checkObjectLeak()
|
||||
deserializeBodies = isConst || oldBodiesPolicy || type.checkObjectLeak()
|
||||
f()
|
||||
} finally {
|
||||
deserializeBodies = oldBodiesPolicy
|
||||
@@ -611,7 +611,7 @@ class IrDeclarationDeserializer(
|
||||
}
|
||||
|
||||
|
||||
private fun deserializeIrField(proto: ProtoField): IrField =
|
||||
private fun deserializeIrField(proto: ProtoField, isConst: Boolean): IrField =
|
||||
withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode ->
|
||||
checkSymbolType<IrFieldSymbol>(symbol)
|
||||
val nameType = BinaryNameAndType.decode(proto.nameType)
|
||||
@@ -633,7 +633,7 @@ class IrDeclarationDeserializer(
|
||||
|
||||
field.usingParent {
|
||||
if (proto.hasInitializer()) {
|
||||
withInitializerGuard {
|
||||
withInitializerGuard(isConst) {
|
||||
initializer = deserializeExpressionBody(proto.initializer)
|
||||
}
|
||||
}
|
||||
@@ -699,7 +699,7 @@ class IrDeclarationDeserializer(
|
||||
}
|
||||
}
|
||||
if (proto.hasBackingField()) {
|
||||
backingField = deserializeIrField(proto.backingField).also {
|
||||
backingField = deserializeIrField(proto.backingField, prop.isConst).also {
|
||||
it.correspondingPropertySymbol = symbol
|
||||
}
|
||||
}
|
||||
@@ -722,7 +722,7 @@ class IrDeclarationDeserializer(
|
||||
val declaration: IrDeclaration = when (proto.declaratorCase!!) {
|
||||
IR_ANONYMOUS_INIT -> deserializeIrAnonymousInit(proto.irAnonymousInit)
|
||||
IR_CONSTRUCTOR -> deserializeIrConstructor(proto.irConstructor)
|
||||
IR_FIELD -> deserializeIrField(proto.irField)
|
||||
IR_FIELD -> deserializeIrField(proto.irField, isConst = false)
|
||||
IR_CLASS -> deserializeIrClass(proto.irClass)
|
||||
IR_FUNCTION -> deserializeIrFunction(proto.irFunction)
|
||||
IR_PROPERTY -> deserializeIrProperty(proto.irProperty)
|
||||
|
||||
Reference in New Issue
Block a user