FIR2IR: set parent correctly (~) for anonymous functions

This commit is contained in:
Mikhail Glukhikh
2019-12-27 16:10:11 +03:00
parent a653feb2dc
commit 6da3c2fa4e
5 changed files with 6 additions and 7 deletions
@@ -237,8 +237,8 @@ class Fir2IrDeclarationStorage(
}
}
internal fun findIrParent(callableMemberDeclaration: FirCallableMemberDeclaration<*>): IrDeclarationParent? {
val firBasedSymbol = callableMemberDeclaration.symbol
internal fun findIrParent(callableDeclaration: FirCallableDeclaration<*>): IrDeclarationParent? {
val firBasedSymbol = callableDeclaration.symbol
val callableId = firBasedSymbol.callableId
val parentClassId = callableId.classId
return if (parentClassId != null) {
@@ -675,7 +675,7 @@ class Fir2IrDeclarationStorage(
fun getIrFunctionSymbol(firFunctionSymbol: FirFunctionSymbol<*>): IrFunctionSymbol {
val firDeclaration = firFunctionSymbol.fir
val irParent = (firDeclaration as? FirCallableMemberDeclaration<*>)?.let { findIrParent(it) }
val irParent = (firDeclaration as? FirCallableDeclaration<*>)?.let { findIrParent(it) }
return when (firDeclaration) {
is FirSimpleFunction -> {
val irDeclaration = getIrFunction(firDeclaration, irParent, shouldLeaveScope = true).apply {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun IntArray.swap(i:Int, j:Int) {
val temp = this[i]
this[i] = this[j]
@@ -11,4 +11,4 @@ FILE fqName:<root> fileName:/extensionLambda.kt
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
BLOCK_BODY
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null
$this: GET_VAR '<this>: kotlin.String declared in <no parent>.<anonymous>' type=kotlin.String origin=null
$this: GET_VAR '<this>: kotlin.String declared in special.<anonymous>' type=kotlin.String origin=null
@@ -109,4 +109,4 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
$receiver: VALUE_PARAMETER name:<this> type:<root>.IInvoke
BLOCK_BODY
CALL 'public open fun invoke (): kotlin.Int [operator] declared in <root>.IInvoke' type=kotlin.Int origin=null
$this: GET_VAR '<this>: <root>.IInvoke declared in <no parent>.<anonymous>' type=<root>.IInvoke origin=null
$this: GET_VAR '<this>: <root>.IInvoke declared in special.<anonymous>' type=<root>.IInvoke origin=null
+1 -1
View File
@@ -27,7 +27,7 @@ FILE fqName:<root> fileName:/builtinMap.kt
$receiver: VALUE_PARAMETER name:<this> type:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>
BLOCK_BODY
CALL 'public open fun put (p0: K1 of <root>.plus, p1: V1 of <root>.plus): V1 of <root>.plus? [operator] declared in java.util.HashMap' type=V1 of <root>.plus? origin=null
$this: GET_VAR '<this>: java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> declared in <no parent>.<anonymous>' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
$this: GET_VAR '<this>: java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> declared in special.<anonymous>' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
p0: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
p1: CALL 'public final fun <get-second> (): V1 of <root>.plus declared in kotlin.Pair' type=V1 of <root>.plus origin=null