Add index() to LocalSignature for more clear access

This commit is contained in:
Roman Artemev
2021-08-06 14:36:40 +03:00
committed by teamcityserver
parent 5a7298808e
commit 2574c00dd9
3 changed files with 5 additions and 3 deletions
@@ -194,6 +194,8 @@ sealed class IdSignature {
override val isLocal: Boolean
get() = true
fun index(): Int = hashSig?.toInt() ?: error("Expected index in ${render()}")
override fun topLevelSignature(): IdSignature {
error("Illegal access: Local Sig does not have toplevel (${render()}")
}
@@ -57,7 +57,7 @@ class DescriptorByIdSignatureFinder(
fqn == MangleConstant.TYPE_PARAMETER_MARKER_NAME || fqn == MangleConstant.TYPE_PARAMETER_MARKER_NAME_SETTER
if (isTypeParameterSig(inner.localFqn)) {
val tpIndex = inner.hashSig?.toInt() ?: error("Expected index in $signature")
val tpIndex = inner.index()
if (container is CallableDescriptor) {
return container.typeParameters[tpIndex]
}
@@ -155,8 +155,8 @@ class IrModuleDeserializerWithBuiltIns(
val classSignature = idSig.container
val classSymbol = resolveFunctionalInterface(classSignature, BinarySymbolData.SymbolKind.CLASS_SYMBOL) as IrClassSymbol
val typeParameterSig = composite.inner as IdSignature.LocalSignature
val typeParameterIndex = typeParameterSig.hashSig ?: error("Expected index for $idSig")
val typeParameter = classSymbol.owner.typeParameters[typeParameterIndex.toInt()]
val typeParameterIndex = typeParameterSig.index()
val typeParameter = classSymbol.owner.typeParameters[typeParameterIndex]
return typeParameter.symbol
}
val publicSig = idSig.asPublic() ?: error("$idSig has to be public")