[AA] Tests: Rewrite sealed class inheritors collection to use the declaration provider

- Now that binary libraries are decompiled to stubs instead of PSI
  files, we cannot collect sealed inheritors from `KtFile`s anymore.
  Since all `KtFile`s and binary library stubs are both indexed by the
  declaration provider, we can collect inheritors from its index
  instead.
- Invalidating all sessions at the end of `prepareSealedClassInheritors`
  fixes some improper resolve phases in lazy resolution test data. While
  the previous implementation requested an uncached resolve session, it
  didn't account for sessions of dependencies still being cached.

^KT-65960
This commit is contained in:
Marco Pennekamp
2024-02-21 20:29:58 +01:00
committed by Space Team
parent 47afd37596
commit e62038f5f3
4 changed files with 101 additions and 72 deletions
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
import org.jetbrains.kotlin.psi.stubs.impl.*
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
import org.jetbrains.kotlin.utils.addToStdlib.flattenTo
import java.util.concurrent.ConcurrentHashMap
public class KotlinStaticDeclarationProvider internal constructor(
@@ -396,6 +397,8 @@ public class KotlinStaticDeclarationProviderFactory(
public fun getAdditionalCreatedKtFiles(): List<KtFile> {
return createdFakeKtFiles
}
public fun getAllKtClasses(): List<KtClassOrObject> = index.classMap.values.flattenTo(mutableListOf())
}
/**