[Linker] Add option to control scope of DescriptorByIdSignatureFinder

Currently DescriptorByIdSignatureFinder performs lookup of descriptor
not only in the given module but also in its dependencies.
This behaviour is incorrect if we have some kind of
relation (e.g. mapping) between moduleDescriptor and found descriptor.
Thus, we add a handle to control search scope.
This commit is contained in:
Sergey Bogolepov
2020-04-21 13:15:29 +07:00
parent 318d4d17ba
commit 0ed0152ee0
2 changed files with 51 additions and 6 deletions
@@ -111,7 +111,10 @@ class JvmIrLinker(currentModule: ModuleDescriptor?, logger: LoggingContext, buil
// TODO: implement proper check whether `idSig` belongs to this module
override fun contains(idSig: IdSignature): Boolean = true
private val descriptorFinder = DescriptorByIdSignatureFinder(moduleDescriptor, manglerDesc)
private val descriptorFinder = DescriptorByIdSignatureFinder(
moduleDescriptor, manglerDesc,
DescriptorByIdSignatureFinder.LookupMode.MODULE_ONLY
)
private fun resolveDescriptor(idSig: IdSignature): DeclarationDescriptor {
return descriptorFinder.findDescriptorBySignature(idSig) ?: error("No descriptor found for $idSig")