diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt index 437331d601e..ca00a332eeb 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt @@ -78,8 +78,10 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F if (declaration.isInline) { val irConstructor = declaration.primaryConstructor!! - // The field getter is used by reflection and cannot be removed here. - declaration.declarations.remove(irConstructor) + // The field getter is used by reflection and cannot be removed here unless it is internal. + declaration.declarations.removeIf { + it == irConstructor || (it is IrFunction && it.isInlineClassFieldGetter && !it.visibility.isPublicAPI) + } buildPrimaryInlineClassConstructor(declaration, irConstructor) buildBoxFunction(declaration) buildUnboxFunction(declaration) diff --git a/compiler/testData/codegen/box/reflection/mapping/inlineClassPrimaryVal.kt b/compiler/testData/codegen/box/reflection/mapping/inlineClassPrimaryVal.kt index 0777ca0029a..5168d57e031 100644 --- a/compiler/testData/codegen/box/reflection/mapping/inlineClassPrimaryVal.kt +++ b/compiler/testData/codegen/box/reflection/mapping/inlineClassPrimaryVal.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT