From 711f36675cc62ae97719c83d4c11cb9189bc42c3 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Tue, 24 Jan 2023 12:44:10 +0100 Subject: [PATCH] CompatibilityMode cleanup Review: https://jetbrains.team/p/kt/reviews/8401 - Drop unused variables - Replace `assert` with `require` because `assert` isn't reliable which makes hard to do any judgements about the code (`-ea` flag must be passed to the VM for the `assert` to be active. And it's hard to know when we the flag is passed). If `assert` was here for the performance reasons then a comment should have been left. - Add the assert message for clearity Because I'm evaluating what will break if KotlinAbiVersion is bumped. And when the code around KotlinAbiVersion is clean it's easier to do the evaluation. --- .../common/serialization/IrModuleDeserializer.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt index 3b4bd4930b9..f0590c76b06 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.util.IdSignature import org.jetbrains.kotlin.library.IrLibrary import org.jetbrains.kotlin.library.KotlinAbiVersion +import org.jetbrains.kotlin.library.KotlinLibraryProperResolverWithAttributes fun IrSymbol.kind(): BinarySymbolData.SymbolKind { return when (this) { @@ -31,7 +32,9 @@ fun IrSymbol.kind(): BinarySymbolData.SymbolKind { class CompatibilityMode(val abiVersion: KotlinAbiVersion) { init { - assert(abiVersion.isCompatible()) + require(abiVersion.isCompatible()) { + "Incompatible KLIB should have been discarded in ${KotlinLibraryProperResolverWithAttributes::libraryMatch.name}" + } } val oldSignatures: Boolean @@ -44,11 +47,7 @@ class CompatibilityMode(val abiVersion: KotlinAbiVersion) { companion object { val LAST_PRIVATE_SIG_ABI_VERSION = KotlinAbiVersion(1, 5, 0) - - val WITH_PRIVATE_SIG = CompatibilityMode(LAST_PRIVATE_SIG_ABI_VERSION) - val WITH_COMMON_SIG = CompatibilityMode(KotlinAbiVersion.CURRENT) - - val CURRENT = WITH_COMMON_SIG + val CURRENT = CompatibilityMode(KotlinAbiVersion.CURRENT) } }