From 5cb4b6848e6cfb78bab80bd4f4304fa74bbcff97 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Wed, 15 Nov 2023 17:07:09 +0100 Subject: [PATCH] Make sure the richest constructor (that includes all variables) is used by @Persistable --- .../java/org/enso/interpreter/caches/ModuleCacheTest.java | 5 ++++- .../java/org/enso/interpreter/dsl/PersistableProcessor.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/runtime/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java b/engine/runtime/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java index 9bdb97db6fe1..f2ff2508ecc8 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java @@ -56,6 +56,9 @@ public void testCompareList() throws Exception { var meta = new ModuleCache.Metadata("hash", "code", CompilationStage.AFTER_CODEGEN.toString()); var cachedIr = module.getCache().deserialize(ensoCtx, arr, meta, null); assertNotNull("IR read", cachedIr); - CompilerTest.assertIR(name, module.getIr(), cachedIr.moduleIR()); + for (var node : ScalaConversions.asJava(cachedIr.moduleIR().preorder())) { + node.passData().prepareForSerialization(ensoCtx.getCompiler().context()); + } + CompilerTest.assertIR(name, ir, cachedIr.moduleIR()); } } \ No newline at end of file diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/PersistableProcessor.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/PersistableProcessor.java index 28d41fc9f829..f6fa969520ee 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/PersistableProcessor.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/PersistableProcessor.java @@ -91,10 +91,10 @@ private boolean generatePersistance(Element orig, Persistable anno) throws IOExc var ea = (ExecutableElement)a; var eb = (ExecutableElement)b; - return ea.getParameters().size() - eb.getParameters().size(); + return eb.getParameters().size() - ea.getParameters().size(); }) .toList(); - if (constructors.size() == 0) { + if (constructors.isEmpty()) { processingEnv.getMessager().printMessage(Kind.ERROR, "There should be exactly one constructor in " + typeElem); return false; }