FIR2IR: set superQualifierSymbol for property access
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a084c5bf7d
commit
0890b8bad3
+20
-13
@@ -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<ConeClassLikeType>()
|
||||
(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<ConeClassLikeType>()
|
||||
(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,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A {
|
||||
open val foo: String = "OK"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A {
|
||||
internal open val field = "F"
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A {
|
||||
internal open val field = "F"
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
package As
|
||||
|
||||
val staticProperty : String = "1"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// Super calls to Throwable properties are not supported
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// Super calls to Throwable properties are not supported
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ FILE fqName:<root> fileName:/qualifiedSuperCalls.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-bar> (): kotlin.Int declared in <root>.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 <get-bar> (): kotlin.Int declared in <root>.ILeft' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: CALL 'public open fun <get-bar> (): kotlin.Int declared in <root>.ILeft' superQualifier='CLASS INTERFACE name:ILeft modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.CBoth declared in <root>.CBoth.<get-bar>' type=<root>.CBoth origin=null
|
||||
other: CALL 'public open fun <get-bar> (): kotlin.Int declared in <root>.IRight' type=kotlin.Int origin=GET_PROPERTY
|
||||
other: CALL 'public open fun <get-bar> (): kotlin.Int declared in <root>.IRight' superQualifier='CLASS INTERFACE name:IRight modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.CBoth declared in <root>.CBoth.<get-bar>' type=<root>.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:
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ FILE fqName:<root> fileName:/superCalls.kt
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-bar> (): kotlin.String declared in <root>.Derived'
|
||||
CALL 'public open fun <get-bar> (): kotlin.String declared in <root>.Base' type=kotlin.String origin=GET_PROPERTY
|
||||
CALL 'public open fun <get-bar> (): kotlin.String declared in <root>.Base' superQualifier='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.<get-bar>' type=<root>.Derived origin=null
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:<root>.Base) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
|
||||
Reference in New Issue
Block a user