From 53d8749b225ed275ec1519260ee5499368e60c47 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 21 Jan 2025 13:10:01 +0200 Subject: [PATCH] [Repl] Clear java finder caches on adding new dependencies between snippets Otherwise, `javaFacade.hasTopLevelClassOf(classId)` in `JvmClassFileBasedSymbolProvider.computePackagePartInfo` will return cached `null` in the situation when the dependency class was accessed in one of the previous snippets without actual dependency --- .../kotlin/scripting/compiler/plugin/impl/K2ReplCompiler.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/scripting/scripting-compiler/src/org/jetbrains/kotlin/scripting/compiler/plugin/impl/K2ReplCompiler.kt b/plugins/scripting/scripting-compiler/src/org/jetbrains/kotlin/scripting/compiler/plugin/impl/K2ReplCompiler.kt index d4799abc3f30b..7befb17b6c533 100644 --- a/plugins/scripting/scripting-compiler/src/org/jetbrains/kotlin/scripting/compiler/plugin/impl/K2ReplCompiler.kt +++ b/plugins/scripting/scripting-compiler/src/org/jetbrains/kotlin/scripting/compiler/plugin/impl/K2ReplCompiler.kt @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.modules.TargetId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade import org.jetbrains.kotlin.scripting.compiler.plugin.ReplCompilerPluginRegistrar import org.jetbrains.kotlin.scripting.compiler.plugin.dependencies.collectScriptsCompilationDependencies import org.jetbrains.kotlin.scripting.compiler.plugin.services.FirReplHistoryProviderImpl @@ -309,6 +310,7 @@ private fun compileImpl( languageVersionSettings = compilerConfiguration.languageVersionSettings, predefinedJavaComponents = state.predefinedJavaComponents, ) + KotlinJavaPsiFacade.getInstance(project).clearPackageCaches() } val session = FirJvmSessionFactory.createModuleBasedSession(