[IR] Replace error("Should not be called") with shouldNotBeCalled()

This commit is contained in:
Sergej Jaskiewicz
2023-11-09 16:24:00 +01:00
committed by Space Team
parent 5a86147e9c
commit 918335e12e
2 changed files with 9 additions and 10 deletions
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrMetadataSourceOwner import org.jetbrains.kotlin.ir.declarations.IrMetadataSourceOwner
import org.jetbrains.kotlin.ir.util.KotlinMangler import org.jetbrains.kotlin.ir.util.KotlinMangler
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
class Ir2FirManglerAdapter(private val delegate: FirMangler) : AbstractKotlinMangler<IrDeclaration>(), class Ir2FirManglerAdapter(private val delegate: FirMangler) : AbstractKotlinMangler<IrDeclaration>(),
KotlinMangler.IrMangler { KotlinMangler.IrMangler {
@@ -26,15 +27,15 @@ class Ir2FirManglerAdapter(private val delegate: FirMangler) : AbstractKotlinMan
override fun IrDeclaration.isExported(compatibleMode: Boolean): Boolean = delegate.run { fir().isExported(compatibleMode) } override fun IrDeclaration.isExported(compatibleMode: Boolean): Boolean = delegate.run { fir().isExported(compatibleMode) }
override fun IrDeclaration.mangleString(compatibleMode: Boolean): String { override fun IrDeclaration.mangleString(compatibleMode: Boolean): String {
error("Should not be called") shouldNotBeCalled()
} }
override fun IrDeclaration.signatureString(compatibleMode: Boolean): String = delegate.run { fir().signatureString(compatibleMode) } override fun IrDeclaration.signatureString(compatibleMode: Boolean): String = delegate.run { fir().signatureString(compatibleMode) }
override fun getMangleComputer(mode: MangleMode, compatibleMode: Boolean): KotlinMangleComputer<IrDeclaration> = override fun getMangleComputer(mode: MangleMode, compatibleMode: Boolean): KotlinMangleComputer<IrDeclaration> =
error("Should not have been reached") shouldNotBeCalled()
override fun getExportChecker(compatibleMode: Boolean): KotlinExportChecker<IrDeclaration> { override fun getExportChecker(compatibleMode: Boolean): KotlinExportChecker<IrDeclaration> {
error("Should not be called") shouldNotBeCalled()
} }
} }
@@ -12,16 +12,15 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.ir.util.IdSignature import org.jetbrains.kotlin.ir.util.IdSignature
import org.jetbrains.kotlin.ir.util.KotlinMangler import org.jetbrains.kotlin.ir.util.KotlinMangler
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
object DisabledDescriptorMangler : KotlinMangler.DescriptorMangler { object DisabledDescriptorMangler : KotlinMangler.DescriptorMangler {
override val String.hashMangle: Long override val String.hashMangle: Long
get() = error("Should not be called") get() = shouldNotBeCalled()
override fun DeclarationDescriptor.isExported(compatibleMode: Boolean): Boolean = override fun DeclarationDescriptor.isExported(compatibleMode: Boolean): Boolean = shouldNotBeCalled()
error("Should not be called")
override fun DeclarationDescriptor.signatureString(compatibleMode: Boolean): String = override fun DeclarationDescriptor.signatureString(compatibleMode: Boolean): String = shouldNotBeCalled()
error("Should not be called")
} }
object DisabledIdSignatureDescriptor : IdSignatureDescriptor(DisabledDescriptorMangler) { object DisabledIdSignatureDescriptor : IdSignatureDescriptor(DisabledDescriptorMangler) {
@@ -33,6 +32,5 @@ object DisabledIdSignatureDescriptor : IdSignatureDescriptor(DisabledDescriptorM
override fun composeAnonInitSignature(descriptor: ClassDescriptor): IdSignature? = null override fun composeAnonInitSignature(descriptor: ClassDescriptor): IdSignature? = null
override fun createSignatureBuilder(type: SpecialDeclarationType): DescriptorBasedSignatureBuilder = override fun createSignatureBuilder(type: SpecialDeclarationType): DescriptorBasedSignatureBuilder = shouldNotBeCalled()
error("Should not be called")
} }