Fir2Ir: repair computation of IR signatures

This commit is contained in:
Georgy Bronnikov
2021-12-26 16:03:35 +03:00
committed by Alexander Udalov
parent ffe1615e9c
commit 4b34648327
2 changed files with 10 additions and 3 deletions
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.backend.common.serialization.mangle.collectForMangle
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticPropertyAccessor
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
import org.jetbrains.kotlin.fir.declarations.utils.isStatic
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
@@ -157,7 +158,8 @@ open class FirJvmMangleComputer(
mangleType(builder, it.typeRef.coneType)
}
receiverTypeRef?.let {
val receiverType = receiverTypeRef ?: (this as? FirPropertyAccessor)?.propertySymbol?.fir?.receiverTypeRef
receiverType?.let {
builder.appendSignature(MangleConstant.EXTENSION_RECEIVER_PREFIX)
mangleType(builder, it.coneType)
}
@@ -323,7 +325,12 @@ open class FirJvmMangleComputer(
constructor.mangleFunction(isCtor = true, isStatic = false, constructor)
override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: Boolean) {
propertyAccessor.mangleFunction(isCtor = false, propertyAccessor.isStatic, propertyAccessor.propertySymbol!!.fir)
if (propertyAccessor is FirSyntheticPropertyAccessor) {
// No need to distinguish between the accessor and its delegate.
visitSimpleFunction(propertyAccessor.delegate, data)
} else {
propertyAccessor.mangleFunction(isCtor = false, propertyAccessor.isStatic, propertyAccessor.propertySymbol!!.fir)
}
}
override fun computeMangle(declaration: FirDeclaration): String {
@@ -158,7 +158,7 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat
}
private fun isTopLevelPrivate(declaration: FirDeclaration, containingClass: ConeClassLikeLookupTag?): Boolean =
containingClass == null && declaration is FirMemberDeclaration && declaration.visibility == Visibilities.Private
containingClass == null && declaration is FirCallableDeclaration && declaration.visibility == Visibilities.Private
private fun FirProperty.getterOrDefault() =
getter ?: FirDefaultPropertyGetter(