[LL] add assertion that module of ktFile and FirBuilder are equivalent
to catch KTIJ-24530, when file was located in production scope of the module but fir was created both for the test source and production
This commit is contained in:
+12
-1
@@ -7,8 +7,10 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.impl.barebone.annotations.ThreadSafe
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents
|
||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
||||
import org.jetbrains.kotlin.analysis.project.structure.getKtModule
|
||||
import org.jetbrains.kotlin.analysis.utils.errors.checkWithAttachmentBuilder
|
||||
import org.jetbrains.kotlin.fir.builder.BodyBuildingMode
|
||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
@@ -20,6 +22,15 @@ internal class LLFirFileBuilder(
|
||||
val moduleComponents: LLFirModuleResolveComponents,
|
||||
) {
|
||||
fun buildRawFirFileWithCaching(ktFile: KtFile): FirFile = moduleComponents.cache.fileCached(ktFile) {
|
||||
checkWithAttachmentBuilder(ktFile.getKtModule() == moduleComponents.module, { "Modules are inconsistent" }) {
|
||||
withEntry("file", ktFile.name)
|
||||
withEntry("file module", ktFile.getKtModule()) {
|
||||
it.toString()
|
||||
}
|
||||
withEntry("components module", moduleComponents.module) {
|
||||
it.toString()
|
||||
}
|
||||
}
|
||||
val bodyBuildingMode = when {
|
||||
ktFile.isScript() -> {
|
||||
// As 'FirScript' content is never transformed, lazy bodies are not replaced with calculated ones even on BODY_RESOLVE.
|
||||
|
||||
Reference in New Issue
Block a user