diff --git a/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/IrPersistance.java b/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/IrPersistance.java index 349bf53a6ff3..bf4f470fd7cf 100644 --- a/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/IrPersistance.java +++ b/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/IrPersistance.java @@ -60,6 +60,10 @@ @Persistable(clazz = Name.BuiltinAnnotation.class, id = 783) @Persistable(clazz = Type.Error.class, id = 784) @Persistable(clazz = Unused.Binding.class, id = 785) +@Persistable(clazz = Unused.PatternBinding.class, id = 786) +@Persistable(clazz = Unused.FunctionArgument.class, id = 787) +@Persistable(clazz = Warning.DuplicatedImport.class, id = 788) +@Persistable(clazz = Warning.WrongBuiltinMethod.class, id = 789) public final class IrPersistance { private IrPersistance() {} @@ -388,28 +392,15 @@ public PersistDiagnosticStorage() { } @Override - protected void writeObject(DiagnosticStorage obj, Output out) throws IOException {} + protected void writeObject(DiagnosticStorage obj, Output out) throws IOException { + out.writeInline(List.class, obj.toList()); + } @Override @SuppressWarnings("unchecked") protected DiagnosticStorage readObject(Input in) throws IOException, ClassNotFoundException { - return new DiagnosticStorage( - (scala.collection.immutable.List) scala.collection.immutable.Nil$.MODULE$); + var diags = in.readInline(List.class); + return new DiagnosticStorage(diags); } } - - @SuppressWarnings("unchecked") - private static scala.collection.immutable.List nil() { - return (scala.collection.immutable.List) scala.collection.immutable.Nil$.MODULE$; - } - - private static scala.collection.immutable.List join( - T head, scala.collection.immutable.List tail) { - return scala.collection.immutable.$colon$colon$.MODULE$.apply(head, tail); - } - - @SuppressWarnings("unchecked") - private static E raise(Class clazz, Throwable t) throws E { - throw (E) t; - } } 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 f991bdf4ae4b..fe6290b9675b 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 @@ -1,22 +1,19 @@ package org.enso.interpreter.caches; import org.enso.compiler.CompilerTest; -import org.enso.compiler.core.IR; -import org.enso.interpreter.Constants; import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.builtin.Builtins; import org.enso.interpreter.test.TestBase; -import org.enso.interpreter.util.ScalaConversions; import org.enso.polyglot.CompilationStage; import org.enso.polyglot.LanguageInfo; import org.enso.polyglot.MethodNames; import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; -import org.junit.Test; +import org.graalvm.polyglot.Source; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; +import org.junit.Test; public class ModuleCacheTest extends TestBase { private static Context ctx; @@ -55,4 +52,30 @@ public void testCompareList() throws Exception { assertNotNull("IR read", cachedIr); CompilerTest.assertIR(name, ir, cachedIr.moduleIR()); } + + + @Test + public void testCompareWithWarning() throws Exception { + var ensoCtx = (EnsoContext) ctx.getBindings(LanguageInfo.ID).invokeMember(MethodNames.TopScope.LEAK_CONTEXT).asHostObject(); + var name = "TestWarning"; + var code = Source.newBuilder("enso", """ + empty x = 42 + """, "TestWarning.enso") + .build(); + + var v = ctx.eval(code).invokeMember(MethodNames.Module.EVAL_EXPRESSION, "empty").execute(-1); + assertEquals(42, v.asInt()); + + var option = ensoCtx.findModule(name); + assertTrue("Module found", option.isPresent()); + var module = option.get(); + var ir = module.getIr().duplicate(true, true, true, true); + var cm = new ModuleCache.CachedModule(ir, CompilationStage.AFTER_CODEGEN, module.getSource()); + byte[] arr = module.getCache().serialize(ensoCtx, cm); + + 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, ir, cachedIr.moduleIR()); + } }