[FIR] Use proper FirProvider in the FirKLibSerializerExtension

3aa84906 changed native metadata serialization to use proper platform
  session, but it caused a new bug: FirKLibSerializerExtension uses
  FirProvider from the passed session to get a containing file of
  serialized declaration to put some extension into the metadata. And
  platform session doesn't contain information about any declarations
  except platform ones

So it's needed to use the proper FirProvider in it, which can be
  extracted from Fir2IrComponents. This provider contains providers from
  all sessions that are being compiled plus providers for top-level
  declarations generated by compiler plugins

^KT-65024 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-01-16 18:39:33 +02:00
committed by Space Team
parent 70d1a2ea8c
commit 0741250b12
5 changed files with 16 additions and 14 deletions
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.fir.moduleData
import org.jetbrains.kotlin.fir.packageFqName
import org.jetbrains.kotlin.fir.pipeline.FirResult
import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
import org.jetbrains.kotlin.fir.serialization.*
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.util.IrMessageLogger
@@ -87,13 +88,14 @@ internal fun PhaseContext.firSerializerBase(
) { firFile, originalSession, originalScopeSession ->
val session = fir2IrOutput?.components?.session ?: originalSession
val scopeSession = fir2IrOutput?.components?.scopeSession ?: originalScopeSession
val firProvider = fir2IrOutput?.components?.firProvider ?: originalSession.firProvider
serializeSingleFirFile(
firFile,
session,
scopeSession,
actualizedFirDeclarations,
FirKLibSerializerExtension(
session, metadataVersion,
session, firProvider, metadataVersion,
fir2IrOutput?.let {
ConstValueProviderImpl(fir2IrOutput.components)
},