[IR] Fixed a problem with signature search

The function findDescriptorBySignature should return null if no such signature has been found
letting the caller to handle this correctly. Fixes https://youtrack.jetbrains.com/issue/KT-50976
This commit is contained in:
Igor Chevdar
2022-01-31 13:39:51 +05:00
parent 554e94a322
commit 949e222305
@@ -151,13 +151,7 @@ class DescriptorByIdSignatureFinderImpl(
} }
val candidates = acc val candidates = acc
return when (candidates.size) { return candidates.singleOrNull() ?: findDescriptorByHash(candidates, signature.id)
1 -> candidates.first()
else -> {
findDescriptorByHash(candidates, signature.id)
?: error("No descriptor found for $signature")
}
}
} }
private fun findDescriptorByHash(candidates: Collection<DeclarationDescriptor>, id: Long?): DeclarationDescriptor? = private fun findDescriptorByHash(candidates: Collection<DeclarationDescriptor>, id: Long?): DeclarationDescriptor? =