From 2ebb797e61632d35f70413c8a0b75b7e218203b4 Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Fri, 3 Jan 2020 13:31:37 +0100 Subject: [PATCH] JVM_IR: Remove accessor for internal inline class properties. --- .../kotlin/backend/jvm/lower/JvmInlineClassLowering.kt | 6 ++++-- .../codegen/box/reflection/mapping/inlineClassPrimaryVal.kt | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) 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