From 20ddaa9ebf39e2e7c2af6edee6ebf4410287e0e0 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 6 Sep 2021 15:17:59 +0300 Subject: [PATCH] Remove redundant upcast in JvmPropertiesLowering #KT-48621 Fixed --- .../kotlin/backend/jvm/lower/JvmPropertiesLowering.kt | 4 +++- compiler/testData/codegen/box/regressions/kt5445.kt | 3 --- compiler/testData/codegen/box/regressions/kt5445_2.kt | 3 --- compiler/testData/codegen/box/syntheticAccessors/jvmField.kt | 3 --- .../kt46597_crossinline_jvmField_property.kt | 3 --- .../kt46597_jvmField_property.kt | 3 --- 6 files changed, 3 insertions(+), 16 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt index 4b75dfbb400..f44f9706366 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.expressions.IrFieldAccessExpression import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.isSubtypeOfClass import org.jetbrains.kotlin.ir.types.makeNotNull import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid @@ -118,7 +119,8 @@ class JvmPropertiesLowering(private val backendContext: JvmBackendContext) : IrE val receiver = expression.dispatchReceiver if (receiver != null) { val propertyParent = irProperty.parent - if (propertyParent is IrClass && propertyParent.symbol != receiver.type.classifierOrNull && + if (propertyParent is IrClass && + receiver.type.classifierOrNull?.isSubtypeOfClass(propertyParent.symbol) != true && expression.superQualifierSymbol == null ) { return irImplicitCast(receiver, propertyParent.defaultType) diff --git a/compiler/testData/codegen/box/regressions/kt5445.kt b/compiler/testData/codegen/box/regressions/kt5445.kt index aace185350e..f0ee7677502 100644 --- a/compiler/testData/codegen/box/regressions/kt5445.kt +++ b/compiler/testData/codegen/box/regressions/kt5445.kt @@ -1,8 +1,5 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR -// - FIR2IR should generate call to fake override - // WITH_RUNTIME // FILE: 1.kt diff --git a/compiler/testData/codegen/box/regressions/kt5445_2.kt b/compiler/testData/codegen/box/regressions/kt5445_2.kt index e58073fc814..68aa1299020 100644 --- a/compiler/testData/codegen/box/regressions/kt5445_2.kt +++ b/compiler/testData/codegen/box/regressions/kt5445_2.kt @@ -1,8 +1,5 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR -// - FIR2IR should generate call to fake override - // WITH_RUNTIME // FILE: 1.kt diff --git a/compiler/testData/codegen/box/syntheticAccessors/jvmField.kt b/compiler/testData/codegen/box/syntheticAccessors/jvmField.kt index be1f11c169b..76c38ef8d7e 100644 --- a/compiler/testData/codegen/box/syntheticAccessors/jvmField.kt +++ b/compiler/testData/codegen/box/syntheticAccessors/jvmField.kt @@ -1,9 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR -// - FIR2IR should generate call to fake override - // FILE: A.kt package a import b.* diff --git a/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_crossinline_jvmField_property.kt b/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_crossinline_jvmField_property.kt index 2122cc60a4c..69b78cabeb0 100644 --- a/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_crossinline_jvmField_property.kt +++ b/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_crossinline_jvmField_property.kt @@ -1,9 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR -// - FIR2IR should generate call to fake override - // FILE: a.kt package a diff --git a/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_jvmField_property.kt b/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_jvmField_property.kt index a3e3f9862a7..df39d043855 100644 --- a/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_jvmField_property.kt +++ b/compiler/testData/codegen/box/syntheticAccessors/protectedMemberReferenceAccessor/kt46597_jvmField_property.kt @@ -1,9 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR -// - FIR2IR should generate call to fake override - // FILE: a.kt package a