From 60d5de56cb65383d9d146ad1d290b04b718bfab5 Mon Sep 17 00:00:00 2001 From: Alexey Merkulov Date: Tue, 15 Aug 2023 20:59:51 +0200 Subject: [PATCH] [Stubs] Fix writing/reading multi file facades The fixed error leaded to the invalid resolve of methods during evaluation, e.g. kotlinx.coroutines#runBlocking should be called from facade BuildersKt instead of BuildersKt__BuildersKt --- .../StubBasedFirDeserializedSymbolProvider.kt | 2 +- .../jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt | 4 ++-- .../kotlin/psi/stubs/impl/KotlinStubOrigin.kt | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/stubBased/deserialization/StubBasedFirDeserializedSymbolProvider.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/stubBased/deserialization/StubBasedFirDeserializedSymbolProvider.kt index 9be4985583d..7d4a12b92e2 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/stubBased/deserialization/StubBasedFirDeserializedSymbolProvider.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/stubBased/deserialization/StubBasedFirDeserializedSymbolProvider.kt @@ -185,7 +185,7 @@ internal open class StubBasedFirDeserializedSymbolProvider( } is KotlinStubOrigin.MultiFileFacade -> { val className = JvmClassName.byInternalName(origin.className) - val facadeClassName = JvmClassName.byInternalName(origin.className) + val facadeClassName = JvmClassName.byInternalName(origin.facadeClassName) JvmStubDeserializedFacadeContainerSource(className, facadeClassName) } else -> { diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt index bfead7fceb2..473422e07f1 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt @@ -23,12 +23,12 @@ object KotlinStubVersions { // Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version // if you are not 100% sure it can be avoided. // Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version. - const val SOURCE_STUB_VERSION = 154 + const val SOURCE_STUB_VERSION = 155 // Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed // or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder). // Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files). - private const val BINARY_STUB_VERSION = 92 + private const val BINARY_STUB_VERSION = 93 // Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile) // Increasing this version will lead to reindexing of all classfiles. diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinStubOrigin.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinStubOrigin.kt index aebf69a96b8..fd408813262 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinStubOrigin.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinStubOrigin.kt @@ -10,6 +10,9 @@ import com.intellij.psi.stubs.StubOutputStream sealed class KotlinStubOrigin { companion object { + private const val FACADE_KIND = 1 + private const val MULTI_FILE_FACADE_KIND = 2 + @JvmStatic fun serialize(origin: KotlinStubOrigin?, dataStream: StubOutputStream) { if (origin == null) { @@ -23,8 +26,8 @@ sealed class KotlinStubOrigin { @JvmStatic fun deserialize(dataStream: StubInputStream): KotlinStubOrigin? { return when (dataStream.readInt()) { - Facade.KIND -> Facade.deserializeContent(dataStream) - MultiFileFacade.KIND -> MultiFileFacade.deserializeContent(dataStream) + FACADE_KIND -> Facade.deserializeContent(dataStream) + MULTI_FILE_FACADE_KIND -> MultiFileFacade.deserializeContent(dataStream) else -> null } } @@ -46,7 +49,7 @@ sealed class KotlinStubOrigin { } } - override val kind: Int get() = KIND + override val kind: Int get() = FACADE_KIND override fun serializeContent(dataStream: StubOutputStream) { dataStream.writeName(className) @@ -67,7 +70,7 @@ sealed class KotlinStubOrigin { } } - override val kind: Int get() = Facade.KIND + override val kind: Int get() = MULTI_FILE_FACADE_KIND override fun serializeContent(dataStream: StubOutputStream) { dataStream.writeName(className)