From 761e47264a4f3b1c6a5b5b86040f68477a4c5cae Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 3 Jul 2020 14:48:42 +0300 Subject: [PATCH] JVM_IR: fix property reference generation for inline class primary val --- .../kotlin/backend/jvm/lower/PropertyReferenceLowering.kt | 4 +++- .../reflection/call/inlineClasses/primaryValOfInlineClass.kt | 3 --- .../box/reflection/mapping/types/inlineClassPrimaryVal.kt | 3 --- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt index 1f145cc4897..25110c957ce 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.backend.jvm.lower.FunctionReferenceLowering.Companio import org.jetbrains.kotlin.backend.jvm.lower.FunctionReferenceLowering.Companion.calculateOwnerKClass import org.jetbrains.kotlin.backend.jvm.lower.FunctionReferenceLowering.Companion.kClassToJavaClass import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isInlineClassFieldGetter import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.ir.IrStatement @@ -119,7 +120,8 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class // private properties in multifile-part classes. val needsDummySignature = getter.owner.correspondingPropertySymbol?.owner?.needsAccessor(getter.owner) == false || - getter.owner.origin == IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR && getter.owner.parentAsClass.isInline + // Internal underlying vals of inline classes have no getter method + getter.owner.isInlineClassFieldGetter && getter.owner.visibility == Visibilities.INTERNAL putValueArgument( 0, diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt index b0409cc5a07..89156e987e5 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt @@ -1,8 +1,5 @@ // IGNORE_BACKEND: JS_IR, JS, NATIVE // IGNORE_BACKEND: JS_IR_ES6 -// IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR -// ^ TODO fix reflection for primary inline class properties with mangled getter method // WITH_REFLECT import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt b/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt index 7a2a4fea241..55cd44661f5 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt @@ -1,8 +1,5 @@ // TARGET_BACKEND: JVM // WITH_REFLECT -// IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR -// ^ TODO fix reflection for primary inline class properties with mangled getter method package test import kotlin.reflect.KCallable