[KLIB] Introduce compatible mode for klibs.

Based on library ABI version linker could decide which signature mode
to be used to guarantee backward compatibility.
This commit is contained in:
Roman Artemev
2021-05-26 19:42:06 +03:00
committed by TeamCityServer
parent 3e99951a66
commit b5c28c1912
38 changed files with 343 additions and 256 deletions
@@ -14,18 +14,15 @@ import org.jetbrains.kotlin.fir.signaturer.FirMangler
@NoMutableState
class FirJvmKotlinMangler(private val session: FirSession) : AbstractKotlinMangler<FirDeclaration>(), FirMangler {
override val FirDeclaration.mangleString: String
get() = getMangleComputer(MangleMode.FULL).computeMangle(this)
override fun FirDeclaration.mangleString(): String = getMangleComputer(MangleMode.FULL).computeMangle(this)
override val FirDeclaration.signatureString: String
get() = getMangleComputer(MangleMode.SIGNATURE).computeMangle(this)
override fun FirDeclaration.signatureString(): String = getMangleComputer(MangleMode.SIGNATURE).computeMangle(this)
override val FirDeclaration.fqnString: String
get() = getMangleComputer(MangleMode.FQNAME).computeMangle(this)
override fun FirDeclaration.fqnString(): String = getMangleComputer(MangleMode.FQNAME).computeMangle(this)
override fun FirDeclaration.isExported(): Boolean = true
override fun FirDeclaration.isExported(compatibleMode: Boolean): Boolean = true
override fun getExportChecker(): KotlinExportChecker<FirDeclaration> {
override fun getExportChecker(compatibleMode: Boolean): KotlinExportChecker<FirDeclaration> {
return object : KotlinExportChecker<FirDeclaration> {
override fun check(declaration: FirDeclaration, type: SpecialDeclarationType): Boolean = true
@@ -40,17 +40,17 @@ class FirBasedSignatureComposer(private val mangler: FirMangler) : Fir2IrSignatu
}
override fun visitConstructor(constructor: FirConstructor, data: Any?) {
hashId = mangler.run { constructor.signatureMangle }
hashId = mangler.run { constructor.signatureMangle() }
setExpected(constructor.isExpect)
}
override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: Any?) {
hashId = mangler.run { simpleFunction.signatureMangle }
hashId = mangler.run { simpleFunction.signatureMangle() }
setExpected(simpleFunction.isExpect)
}
override fun visitProperty(property: FirProperty, data: Any?) {
hashId = mangler.run { property.signatureMangle }
hashId = mangler.run { property.signatureMangle() }
setExpected(property.isExpect)
}