Skip to content

Commit 0c8b50d

Browse files
author
Oleksandr Karpovich
committedMar 5, 2025
CMP-7571: improve signature generation for an artificial stability getter
1 parent cb387d5 commit 0c8b50d

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed
 

‎compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/PartiallyLinkedIrTreePatcher.kt

+22-29
Original file line numberDiff line numberDiff line change
@@ -533,36 +533,29 @@ internal class PartiallyLinkedIrTreePatcher(
533533

534534
val stabilityField = owner
535535

536-
val stabilityGetter = builtIns.irFactory.createSimpleFunction(
537-
startOffset = UNDEFINED_OFFSET,
538-
endOffset = UNDEFINED_OFFSET,
539-
name = Name.identifier(getterName),
540-
returnType = stabilityField.type,
541-
visibility = DescriptorVisibilities.PUBLIC,
542-
origin = PartiallyLinkedDeclarationOrigin.AUXILIARY_GENERATED_DECLARATION,
543-
isInline = false,
544-
isExpect = false,
545-
modality = Modality.FINAL,
546-
// k/wasm and k/js rely on signatures, therefore we must set a "unique" signature here
547-
symbol = IrSimpleFunctionSymbolImpl(signature = IdSignature.LoweredDeclarationSignature(parentField.symbol.signature!!, -1, 0)),
548-
isTailrec = false,
549-
isSuspend = false,
550-
isOperator = false,
551-
isInfix = false,
552-
).also { fn ->
553-
fn.parent = parent
554-
fn.body = builtIns.irFactory.createBlockBody(
555-
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
556-
listOf(
557-
IrReturnImpl(
558-
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
559-
builtIns.nothingType,
560-
fn.symbol,
561-
IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, this, stabilityField.type),
536+
val stabilityGetter = builtIns.irFactory.stageController.restrictTo(parentField) {
537+
builtIns.irFactory.buildFun {
538+
startOffset = UNDEFINED_OFFSET
539+
endOffset = UNDEFINED_OFFSET
540+
name = Name.identifier(getterName)
541+
returnType = stabilityField.type
542+
visibility = DescriptorVisibilities.PUBLIC
543+
origin = PartiallyLinkedDeclarationOrigin.AUXILIARY_GENERATED_DECLARATION
544+
}.also { fn ->
545+
fn.parent = parent
546+
fn.body = builtIns.irFactory.createBlockBody(
547+
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
548+
listOf(
549+
IrReturnImpl(
550+
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
551+
builtIns.nothingType,
552+
fn.symbol,
553+
IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, this, stabilityField.type),
554+
),
562555
),
563-
),
564-
)
565-
parent.addChild(fn)
556+
)
557+
parent.addChild(fn)
558+
}
566559
}
567560

568561
return stabilityGetter

0 commit comments

Comments
 (0)
Please sign in to comment.