Codegen: register i/o File instead of PSI for module mapping...

because there are no PSI files in FIR + LT, so missing mapping hurts IC
This commit is contained in:
Ilya Chernikov
2021-12-24 14:59:07 +01:00
committed by teamcity
parent 275135a1b2
commit a8594e9ce8
2 changed files with 11 additions and 5 deletions
@@ -241,19 +241,24 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull @NotNull
public PackageCodegen forPackage(@NotNull FqName fqName, @NotNull Collection<KtFile> files) { public PackageCodegen forPackage(@NotNull FqName fqName, @NotNull Collection<KtFile> files) {
assert !isDone : "Already done!"; assert !isDone : "Already done!";
registerSourceFiles(files); sourceFiles.addAll(toIoFilesIgnoringNonPhysical(files));
return new PackageCodegenImpl(state, files, fqName); return new PackageCodegenImpl(state, files, fqName);
} }
@NotNull @NotNull
public MultifileClassCodegen forMultifileClass(@NotNull FqName facadeFqName, @NotNull Collection<KtFile> files) { public MultifileClassCodegen forMultifileClass(@NotNull FqName facadeFqName, @NotNull Collection<KtFile> files) {
assert !isDone : "Already done!"; assert !isDone : "Already done!";
registerSourceFiles(files); sourceFiles.addAll(toIoFilesIgnoringNonPhysical(files));
return new MultifileClassCodegenImpl(state, files, facadeFqName); return new MultifileClassCodegenImpl(state, files, facadeFqName);
} }
public void registerSourceFiles(@NotNull Collection<KtFile> files) { public void registerSourceFiles(@NotNull Collection<File> files) {
sourceFiles.addAll(toIoFilesIgnoringNonPhysical(files)); for (File file : files) {
// We ignore non-physical files here, because this code is needed to tell the make what inputs affect which outputs
// a non-physical file cannot be processed by make
if (file == null) continue;
sourceFiles.add(file);
}
} }
@NotNull @NotNull
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
import org.jetbrains.kotlin.backend.common.phaser.* import org.jetbrains.kotlin.backend.common.phaser.*
import org.jetbrains.kotlin.backend.common.serialization.DescriptorByIdSignatureFinderImpl import org.jetbrains.kotlin.backend.common.serialization.DescriptorByIdSignatureFinderImpl
import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods
import org.jetbrains.kotlin.backend.jvm.ir.getIoFile
import org.jetbrains.kotlin.backend.jvm.ir.getKtFile import org.jetbrains.kotlin.backend.jvm.ir.getKtFile
import org.jetbrains.kotlin.backend.jvm.serialization.DisabledIdSignatureDescriptor import org.jetbrains.kotlin.backend.jvm.serialization.DisabledIdSignatureDescriptor
import org.jetbrains.kotlin.backend.jvm.serialization.JvmIdSignatureDescriptor import org.jetbrains.kotlin.backend.jvm.serialization.JvmIdSignatureDescriptor
@@ -264,7 +265,7 @@ open class JvmIrCodegenFactory(
/* JvmBackendContext creates new unbound symbols, have to resolve them. */ /* JvmBackendContext creates new unbound symbols, have to resolve them. */
ExternalDependenciesGenerator(symbolTable, irProviders).generateUnboundSymbolsAsDependencies() ExternalDependenciesGenerator(symbolTable, irProviders).generateUnboundSymbolsAsDependencies()
context.state.factory.registerSourceFiles(irModuleFragment.files.map(IrFile::getKtFile)) context.state.factory.registerSourceFiles(irModuleFragment.files.map(IrFile::getIoFile))
phases.invokeToplevel(phaseConfig, context, irModuleFragment) phases.invokeToplevel(phaseConfig, context, irModuleFragment)