[K/N] Consolidate forward declarations handling

This is refactoring in preparation for KT-59764.
Names and layout of forward declarations related classes
was copy-pasted many times over compiler code.

Implementing KT-59764 would require copy-pasting it two more times.
So instead of doing this it was put in single place.

No behaviour changes intended in this commit.
This commit is contained in:
Pavel Kunyavskiy
2023-07-03 14:49:03 +02:00
committed by Space Team
parent 0179b45840
commit ef9413108b
16 changed files with 130 additions and 113 deletions
+1
View File
@@ -16,6 +16,7 @@ dependencies {
api(project(":compiler:fir:checkers:checkers.native"))
api(project(":js:js.frontend"))
implementation(project(":core:compiler.common.native"))
implementation(project(":compiler:fir:resolve"))
implementation(project(":compiler:fir:fir-serialization"))
implementation(project(":compiler:fir:fir2ir:jvm-backend"))
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.fir.types.constructClassType
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.includedForwardDeclarations
import org.jetbrains.kotlin.library.isInterop
import org.jetbrains.kotlin.library.metadata.impl.ForwardDeclarationKind
import org.jetbrains.kotlin.name.NativeForwardDeclarationKind
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -41,7 +41,7 @@ class NativeForwardDeclarationsSymbolProvider(
private val kotlinLibraries: Collection<KotlinLibrary>,
) : FirSymbolProvider(session) {
private companion object {
private val validPackages = ForwardDeclarationKind.packageFqNameToKind.keys
private val validPackages = NativeForwardDeclarationKind.packageFqNameToKind.keys
}
private val includedForwardDeclarations: Set<ClassId> by lazy {
@@ -77,7 +77,7 @@ class NativeForwardDeclarationsSymbolProvider(
session.firCachesFactory.createCache(::createSyntheticForwardDeclarationClass)
private fun createSyntheticForwardDeclarationClass(classId: ClassId): FirClassLikeSymbol<*>? {
val forwardDeclarationKind = ForwardDeclarationKind.packageFqNameToKind[classId.packageFqName] ?: return null
val forwardDeclarationKind = NativeForwardDeclarationKind.packageFqNameToKind[classId.packageFqName] ?: return null
val symbol = FirRegularClassSymbol(classId)