From d3816961a68b68b971e7811bbc9df70675cdba1b Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Tue, 10 Sep 2024 15:24:57 +0100 Subject: [PATCH] Re-compile module if IdMap is present (#11032) Loading IR caches and IdMap for a module don't play very well. Rather than complicating logic and introducing yet another re-compilation request let's not even attempt to deserialize a module if IdMap is present. The cost of compiling a single module (right now containing the project itself) is negligble, compared to a possibility of bugs that we've encountered so far. (cherry picked from commit 62e15696ec6c58eb38eaea506d5f600c03cd256f) --- .../scala/org/enso/compiler/Compiler.scala | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/engine/runtime-compiler/src/main/scala/org/enso/compiler/Compiler.scala b/engine/runtime-compiler/src/main/scala/org/enso/compiler/Compiler.scala index e68b0dac8730..95d96e71399d 100644 --- a/engine/runtime-compiler/src/main/scala/org/enso/compiler/Compiler.scala +++ b/engine/runtime-compiler/src/main/scala/org/enso/compiler/Compiler.scala @@ -25,11 +25,7 @@ import org.enso.compiler.core.EnsoParser import org.enso.compiler.data.CompilerConfig import org.enso.compiler.pass.PassManager import org.enso.compiler.pass.analyse._ -import org.enso.compiler.phase.{ - IdMapProcessor, - ImportResolver, - ImportResolverAlgorithm -} +import org.enso.compiler.phase.{ImportResolver, ImportResolverAlgorithm} import org.enso.editions.LibraryName import org.enso.pkg.QualifiedName import org.enso.common.CompilationStage @@ -562,25 +558,11 @@ class Compiler( ) context.updateModule(module, _.resetScope()) - if (useCaches) { - if (context.deserializeModule(this, module)) { - val updatedIr = - IdMapProcessor.updateIr( - context.getIr(module), - context.getIdMap(module) - ) - if (updatedIr != null) { - context.updateModule( - module, - u => { - u.resetScope() - u.ir(updatedIr) - u.compilationStage(CompilationStage.AFTER_PARSING) - } - ) - } - return - } + if ( + useCaches && context.getIdMap(module) == null && context + .deserializeModule(this, module) + ) { + return } uncachedParseModule(module, isGenDocs)