[FIR] Properly handle declarations from other source sessions in FirPredicateBasedProvider

^KT-57083 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-03-16 14:19:55 +02:00
committed by Space Team
parent 644391a8e0
commit 507ef3e951
4 changed files with 41 additions and 0 deletions
@@ -90,6 +90,14 @@ class FirPredicateBasedProviderImpl(private val session: FirSession) : FirPredic
// ---------------------------------- Matching ----------------------------------
override fun matches(predicate: AbstractPredicate<*>, declaration: FirDeclaration): Boolean {
/*
* If declaration came from the other source session we should delegate to provider from
* that session, because it stores all caches about its own declarations
*/
val declarationSession = declaration.moduleData.session
if (declarationSession.kind == FirSession.Kind.Source && declarationSession !== session) {
return declarationSession.predicateBasedProvider.matches(predicate, declaration)
}
return when (predicate) {
is DeclarationPredicate -> predicate.accept(declarationPredicateMatcher, declaration)
is LookupPredicate -> predicate.accept(lookupPredicateMatcher, declaration)