KT-63096 [LL] Use full module resolution scope to create KotlinAnnotationsResolver

`KotlinAnnotationsResolver` must see everything that is resolvable from
the current module; otherwise it will not work properly.

The previous scope was the module itself + its binary dependencies
(jars).
Now the scope will contain the module itself and ALL its dependencies,
including other modules.

^KT-63096 Fixed
This commit is contained in:
Roman Golyshev
2023-11-02 13:57:59 +01:00
committed by teamcity
parent 296d7153e6
commit bda677d2ad
2 changed files with 3 additions and 4 deletions
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSourcesSess
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.LLFirExceptionHandler
import org.jetbrains.kotlin.analysis.project.structure.KtCompilerPluginsProvider
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
import org.jetbrains.kotlin.analysis.project.structure.moduleScopeProvider
import org.jetbrains.kotlin.analysis.providers.KotlinResolutionScopeProvider
import org.jetbrains.kotlin.analysis.providers.createAnnotationResolver
import org.jetbrains.kotlin.analysis.providers.createDeclarationProvider
import org.jetbrains.kotlin.fir.FirExceptionHandler
@@ -76,11 +76,10 @@ internal fun FirSession.registerCompilerPluginExtensions(project: Project, modul
@SessionConfiguration
internal fun LLFirSourcesSession.registerCompilerPluginServices(
contentScope: GlobalSearchScope,
project: Project,
module: KtSourceModule
) {
val projectWithDependenciesScope = contentScope.uniteWith(project.moduleScopeProvider.getModuleLibrariesScope(module))
val projectWithDependenciesScope = KotlinResolutionScopeProvider.getInstance(project).getResolutionScope(module)
val annotationsResolver = project.createAnnotationResolver(projectWithDependenciesScope)
// We need FirRegisteredPluginAnnotations and FirPredicateBasedProvider during extensions' registration process
@@ -281,7 +281,7 @@ internal abstract class LLFirAbstractSessionFactory(protected val project: Proje
register(FirProvider::class, firProvider)
register(FirLazyDeclarationResolver::class, LLFirLazyDeclarationResolver())
registerCompilerPluginServices(firProvider.searchScope, project, module)
registerCompilerPluginServices(project, module)
registerCompilerPluginExtensions(project, module)
registerCommonComponentsAfterExtensionsAreConfigured()