[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
@@ -0,0 +1,37 @@
// LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: ANY
// TARGET_BACKEND: JVM_IR
// MODULE: common
// FILE: Base.kt
expect interface Base
// MODULE: jvm()()(common)
// FILE: Property.kt
public actual interface Base {
fun getValue(): PropType // /Base.PropType
interface PropType {
val name: String
}
}
// FILE: Derived.java
public abstract class Derived implements Base {
@Override
public Base.PropType getValue() { // /Base/PropType
return new Base.PropType() {
@Override
public String getName() {
return "OK";
}
};
}
}
// FILE: main.kt
class Impl : Derived()
fun box(): String {
return Impl().value.name
}