diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 7ba47fcaa15..a33267a1fd2 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -173,19 +173,19 @@ internal class CallAndReferenceGenerator( } } } + var superQualifierSymbol: IrClassSymbol? = null + if (qualifiedAccess.dispatchReceiver is FirQualifiedAccess) { + val dispatchReceiverReference = (qualifiedAccess.dispatchReceiver as FirQualifiedAccess).calleeReference + if (dispatchReceiverReference is FirSuperReference) { + val coneSuperType = dispatchReceiverReference.superTypeRef.coneTypeSafe() + (coneSuperType?.lookupTag?.toSymbol(session) as? FirClassSymbol<*>)?.let { + superQualifierSymbol = classifierStorage.getIrClassSymbol(it) + } + } + } when (symbol) { is IrConstructorSymbol -> IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, symbol) is IrSimpleFunctionSymbol -> { - var superQualifierSymbol: IrClassSymbol? = null - if (qualifiedAccess.dispatchReceiver is FirQualifiedAccess) { - val dispatchReceiverReference = (qualifiedAccess.dispatchReceiver as FirQualifiedAccess).calleeReference - if (dispatchReceiverReference is FirSuperReference) { - val coneSuperType = dispatchReceiverReference.superTypeRef.coneTypeSafe() - (coneSuperType?.lookupTag?.toSymbol(session) as? FirClassSymbol<*>)?.let { - superQualifierSymbol = classifierStorage.getIrClassSymbol(it) - } - } - } IrCallImpl( startOffset, endOffset, type, symbol, origin = qualifiedAccess.calleeReference.statementOrigin(), @@ -196,8 +196,14 @@ internal class CallAndReferenceGenerator( val getter = symbol.owner.getter val backingField = symbol.owner.backingField when { - getter != null -> IrCallImpl(startOffset, endOffset, type, getter.symbol, origin = IrStatementOrigin.GET_PROPERTY) - backingField != null -> IrGetFieldImpl(startOffset, endOffset, backingField.symbol, type) + getter != null -> IrCallImpl( + startOffset, endOffset, type, getter.symbol, origin = IrStatementOrigin.GET_PROPERTY, + superQualifierSymbol = superQualifierSymbol + ) + backingField != null -> IrGetFieldImpl( + startOffset, endOffset, backingField.symbol, type, + superQualifierSymbol = superQualifierSymbol + ) else -> IrErrorCallExpressionImpl( startOffset, endOffset, type, description = "No getter or backing field found for ${qualifiedAccess.calleeReference.render()}" @@ -206,7 +212,8 @@ internal class CallAndReferenceGenerator( } is IrFieldSymbol -> IrGetFieldImpl( startOffset, endOffset, symbol, type, - origin = IrStatementOrigin.GET_PROPERTY.takeIf { qualifiedAccess.calleeReference !is FirDelegateFieldReference } + origin = IrStatementOrigin.GET_PROPERTY.takeIf { qualifiedAccess.calleeReference !is FirDelegateFieldReference }, + superQualifierSymbol = superQualifierSymbol ) is IrValueSymbol -> IrGetValueImpl( startOffset, endOffset, type, symbol, diff --git a/compiler/testData/codegen/box/classes/kt2566_2.kt b/compiler/testData/codegen/box/classes/kt2566_2.kt index b119af85615..5590c5ecf74 100644 --- a/compiler/testData/codegen/box/classes/kt2566_2.kt +++ b/compiler/testData/codegen/box/classes/kt2566_2.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR open class A { open val foo: String = "OK" } diff --git a/compiler/testData/codegen/box/mangling/internalOverrideSuperCall.kt b/compiler/testData/codegen/box/mangling/internalOverrideSuperCall.kt index e5530d5d9e3..64424c1dd80 100644 --- a/compiler/testData/codegen/box/mangling/internalOverrideSuperCall.kt +++ b/compiler/testData/codegen/box/mangling/internalOverrideSuperCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { internal open val field = "F" diff --git a/compiler/testData/codegen/box/mangling/publicOverrideSuperCall.kt b/compiler/testData/codegen/box/mangling/publicOverrideSuperCall.kt index 40bcb6b6077..422f510101e 100644 --- a/compiler/testData/codegen/box/mangling/publicOverrideSuperCall.kt +++ b/compiler/testData/codegen/box/mangling/publicOverrideSuperCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { internal open val field = "F" diff --git a/compiler/testData/codegen/box/properties/generalAccess.kt b/compiler/testData/codegen/box/properties/generalAccess.kt index eddfd6d0f66..577d9ab7e13 100644 --- a/compiler/testData/codegen/box/properties/generalAccess.kt +++ b/compiler/testData/codegen/box/properties/generalAccess.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR package As val staticProperty : String = "1" diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt b/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt index f89f7029996..deb29039e10 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // Super calls to Throwable properties are not supported // IGNORE_BACKEND: JS_IR diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt b/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt index 79197fe2c82..d33162bd698 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // Super calls to Throwable properties are not supported // IGNORE_BACKEND: JS_IR diff --git a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt index 4a4914bb52b..d6a6f1d37ff 100644 --- a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt +++ b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt @@ -72,9 +72,9 @@ FILE fqName: fileName:/qualifiedSuperCalls.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .CBoth' CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS - $this: CALL 'public open fun (): kotlin.Int declared in .ILeft' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public open fun (): kotlin.Int declared in .ILeft' superQualifier='CLASS INTERFACE name:ILeft modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .CBoth declared in .CBoth.' type=.CBoth origin=null - other: CALL 'public open fun (): kotlin.Int declared in .IRight' type=kotlin.Int origin=GET_PROPERTY + other: CALL 'public open fun (): kotlin.Int declared in .IRight' superQualifier='CLASS INTERFACE name:IRight modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .CBoth declared in .CBoth.' type=.CBoth origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/classes/superCalls.fir.txt b/compiler/testData/ir/irText/classes/superCalls.fir.txt index de21bc92fcb..14086d8c7bd 100644 --- a/compiler/testData/ir/irText/classes/superCalls.fir.txt +++ b/compiler/testData/ir/irText/classes/superCalls.fir.txt @@ -53,7 +53,7 @@ FILE fqName: fileName:/superCalls.kt $this: VALUE_PARAMETER name: type:.Derived BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Derived' - CALL 'public open fun (): kotlin.String declared in .Base' type=kotlin.String origin=GET_PROPERTY + CALL 'public open fun (): kotlin.String declared in .Base' superQualifier='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' type=kotlin.String origin=GET_PROPERTY $this: GET_VAR ': .Derived declared in .Derived.' type=.Derived origin=null FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:.Base) returnType:kotlin.Int [fake_override] overridden: