From f19859db4e4890f145860e32ae51b3f6b148f682 Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Thu, 18 Jan 2024 16:17:23 +0100 Subject: [PATCH] [Tests] Do not add .java-files of whole project to contentScope in K2 Previously, the code was calling into TopDownAnalyzerFacadeForJVM.newModuleSearchScope, which includes AllJavaSourcesInProjectScope. This lead to .java-sources being incorrectly attributed to wrong modules in tests, which, in turn, could've introduced undesired behaviour around module-dependent checks (e.g. whether a variable is from the other module and thus can't be smartcasted) --- .../project/structure/KtSourceModuleByCompilerConfiguration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleByCompilerConfiguration.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleByCompilerConfiguration.kt index a0fed6ea7ed..e20d539f86d 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleByCompilerConfiguration.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleByCompilerConfiguration.kt @@ -125,7 +125,7 @@ class KtSourceModuleByCompilerConfiguration( override val ktModule: KtModule get() = this override val contentScope: GlobalSearchScope = - TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, psiFiles.filterIsInstance()) + GlobalSearchScope.filesScope(project, psiFiles.map { it.virtualFile }) } class KtScriptModuleByCompilerConfiguration(