[FIR] Unregister java element finders from previous sessions

The problem here is that for common session we register `FirJavaElementFinder`
  which provides light classes based on expect classes. And then
  at the start of analysis of jvm module we register one another
  `FirJavaElementFinder`, which sees actual classes and uses them to
  build light classes

But, because class ids of expect and actual class pair are the same and
  element finders are ordered by creation order, when java resolve tries
  to resolve some class, it founds light class based on expect class,
  even if we are already in platform session

To fix this problem, it was decided to unregister all previous element
  finders on creation of each new session, so old finders won't interfere
  with analysis

^KT-63612 Fixed
^KT-64296
This commit is contained in:
Dmitriy Novozhilov
2023-12-07 17:21:39 +02:00
committed by Space Team
parent e58b5e7d22
commit f4e3203cd8
9 changed files with 82 additions and 6 deletions
@@ -799,7 +799,7 @@ class KotlinCoreEnvironment private constructor(
// exception from `ExtensionPointImpl.doRegisterExtension`, because the registered extension can no longer be found
// when the project is being disposed.
// For example, see the `unregisterExtension` call in `GenerationUtils.compileFilesUsingFrontendIR`.
// TODO: refactor this to avoid registering unneeded extensions in the first place, and avoid using deprecated API.
// TODO: refactor this to avoid registering unneeded extensions in the first place, and avoid using deprecated API. (KT-64296)
@Suppress("DEPRECATION")
PsiElementFinder.EP.getPoint(project).registerExtension(JavaElementFinder(this))
@Suppress("DEPRECATION")