diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/core/ir/MetadataStorageTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/core/ir/MetadataStorageTest.scala index 1f2fdf65582a..07a0c187d29c 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/core/ir/MetadataStorageTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/core/ir/MetadataStorageTest.scala @@ -159,7 +159,7 @@ class MetadataStorageTest extends CompilerTest { meta1.update(TestPass1, meta) meta2.update(TestPass1, meta) - meta1 shouldNot equal(meta2) + meta1 shouldEqual meta2 } def newMetadataStorage(init: Seq[MetadataPair[_]]): MetadataStorage = { @@ -201,8 +201,8 @@ class MetadataStorageTest extends CompilerTest { ) ) - meta.duplicate shouldNot equal(meta) - meta.duplicate shouldNot equal(expected) + meta.duplicate shouldEqual meta + meta.duplicate shouldEqual expected } "enforce safe construction" in { diff --git a/engine/runtime-parser/src/main/java/org/enso/compiler/core/IR.java b/engine/runtime-parser/src/main/java/org/enso/compiler/core/IR.java index 2d3a856ae3a2..de30c22fbfac 100644 --- a/engine/runtime-parser/src/main/java/org/enso/compiler/core/IR.java +++ b/engine/runtime-parser/src/main/java/org/enso/compiler/core/IR.java @@ -1,6 +1,5 @@ package org.enso.compiler.core; -import java.util.Comparator; import java.util.UUID; import java.util.function.Consumer; import java.util.function.Function; @@ -29,24 +28,6 @@ *

See also: Note [IR Equality and hashing] */ public interface IR { - /** - * Compares IR structure, but not metadata neither diagnostics. A special comparator used by - * Persistance API to perform some rare consistency checks. - */ - public static final Comparator STRUCTURE_COMPARATOR = - (aIr, bIr) -> { - if (aIr == bIr) { - return 0; - } - var aCopy = aIr.duplicate(true, false, false, true); - var bCopy = bIr.duplicate(true, false, false, true); - - if (aCopy.equals(bCopy)) { - return 0; - } - return System.identityHashCode(aIr) - System.identityHashCode(bIr); - }; - /** * Storage for metadata that the node has been tagged with as the result of various compiler * passes. 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 4dd42faf9462..d317951014c2 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 @@ -3,7 +3,6 @@ import java.io.IOException; import java.util.AbstractList; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.Map; import java.util.UUID; import org.enso.compiler.core.ir.expression.Application; @@ -445,33 +444,6 @@ protected Seq readObject(Input in) throws IOException, ClassNotFoundException { } } - @ServiceProvider(service = Persistance.class) - public static final class PersistMetadataStorage extends Persistance { - public PersistMetadataStorage() { - super(MetadataStorage.class, false, 389); - } - - @Override - @SuppressWarnings("unchecked") - protected void writeObject(MetadataStorage obj, Output out) throws IOException { - var map = new LinkedHashMap(); - obj.map( - (processingPass, data) -> { - map.put(processingPass, data); - return null; - }); - out.writeInline(java.util.Map.class, map); - } - - @Override - @SuppressWarnings("unchecked") - protected MetadataStorage readObject(Input in) throws IOException, ClassNotFoundException { - var map = in.readInline(java.util.Map.class); - var storage = new MetadataStorage(map); - return storage; - } - } - @ServiceProvider(service = Persistance.class) public static final class PersistDiagnosticStorage extends Persistance { public PersistDiagnosticStorage() { diff --git a/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/MetadataStorage.java b/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/MetadataStorage.java index e0ddd703ae47..4d80ba523ebe 100644 --- a/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/MetadataStorage.java +++ b/engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/MetadataStorage.java @@ -11,18 +11,25 @@ import java.util.function.BiFunction; import java.util.stream.Collectors; import org.enso.compiler.core.CompilerStub; +import org.enso.persist.Persistable; import scala.Option; /** Stores metadata for the various passes. */ +@Persistable(id = 398) public final class MetadataStorage { private Map metadata; + /** Constructs empty, ready to be populated metadata. */ public MetadataStorage() { this(Collections.emptyMap()); } - public MetadataStorage(Map init) { - this.metadata = init; + MetadataStorage(Map metaValues) { + this.metadata = metaValues; + } + + final Map metaValues() { + return this.metadata; } /** @@ -82,6 +89,15 @@ public Option get(ProcessingPass pass) { return Option.apply(prev); } + /** + * Creates a shallow copy of `this`. Use when re-assigning metadata from one IR to another. + * + * @return a shallow copy of `this` + */ + public MetadataStorage copy() { + return new MetadataStorage(metadata); + } + /** * Creates a deep copy of `this`. * @@ -214,7 +230,7 @@ public boolean equals(Object obj) { return true; } if (obj instanceof MetadataStorage other) { - return this.metadata == other.metadata; + return this.metadata.equals(other.metadata); } return false; } diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/CallArgument.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/CallArgument.scala index a1bc76eb21f2..9d8f14601a0b 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/CallArgument.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/CallArgument.scala @@ -72,7 +72,7 @@ object CallArgument { name != this.name || value != this.value || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/DefinitionArgument.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/DefinitionArgument.scala index 2f34585fa86f..fd820cd62a72 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/DefinitionArgument.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/DefinitionArgument.scala @@ -123,7 +123,7 @@ object DefinitionArgument { || defaultValue != this.defaultValue || suspended != this.suspended || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Empty.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Empty.scala index 698246dd0f93..849d58cd9401 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Empty.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Empty.scala @@ -35,7 +35,7 @@ sealed case class Empty( ): Empty = { if ( location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Expression.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Expression.scala index 2024cb0f24c6..55398add4219 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Expression.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Expression.scala @@ -90,7 +90,7 @@ object Expression { || returnValue != this.returnValue || suspended != this.suspended || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -231,7 +231,7 @@ object Expression { name != this.name || expression != this.expression || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Function.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Function.scala index 77f47b10968c..021e0c1b57cb 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Function.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Function.scala @@ -117,7 +117,7 @@ object Function { || body != this.body || location != this.location || canBeTCO != this.canBeTCO - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -283,7 +283,7 @@ object Function { || isPrivate != this.isPrivate || location != this.location || canBeTCO != this.canBeTCO - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Literal.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Literal.scala index 52d41f2ca739..a5383ca8a336 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Literal.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Literal.scala @@ -65,7 +65,7 @@ object Literal { base != this.base || value != this.value || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -197,7 +197,7 @@ object Literal { if ( text != this.text || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Module.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Module.scala index 428b054af6d6..b0e95f373572 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Module.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Module.scala @@ -80,7 +80,7 @@ final case class Module( || bindings != this.bindings || isPrivate != this.isPrivate || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Name.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Name.scala index 8cbd5e328c2b..c4be29a77458 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Name.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Name.scala @@ -76,7 +76,7 @@ object Name { typePointer != this.typePointer || methodName != this.methodName || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -246,7 +246,7 @@ object Name { if ( parts != this.parts || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -318,7 +318,7 @@ object Name { ): Blank = { if ( location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -400,7 +400,7 @@ object Name { if ( specialName != this.specialName || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -506,7 +506,7 @@ object Name { || isMethod != this.isMethod || location != this.location || originalName != this.originalName - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -616,7 +616,7 @@ object Name { if ( name != this.name || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -711,7 +711,7 @@ object Name { name != this.name || expression != this.expression || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -822,7 +822,7 @@ object Name { if ( synthetic != this.synthetic || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -921,7 +921,7 @@ object Name { ): SelfType = { if ( location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Pattern.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Pattern.scala index 3343e892c225..7986ff635034 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Pattern.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Pattern.scala @@ -66,7 +66,7 @@ object Pattern { if ( name != this.name || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -169,7 +169,7 @@ object Pattern { constructor != this.constructor || fields != this.fields || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -324,7 +324,7 @@ object Pattern { if ( literal != this.literal || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -429,7 +429,7 @@ object Pattern { name != this.name || tpe != this.tpe || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -549,7 +549,7 @@ object Pattern { if ( doc != this.doc || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Type.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Type.scala index 1f8590755174..912a6cf848c8 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Type.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/Type.scala @@ -54,7 +54,7 @@ object Type { args != this.args || result != this.result || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -171,7 +171,7 @@ object Type { || signature != this.signature || comment != this.comment || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -287,7 +287,7 @@ object Type { typed != this.typed || context != this.context || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -399,7 +399,7 @@ object Type { typed != this.typed || error != this.error || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Application.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Application.scala index b13add81995c..1778b046c156 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Application.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Application.scala @@ -86,7 +86,7 @@ object Application { || arguments != this.arguments || hasDefaultsSuspended != this.hasDefaultsSuspended || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -203,7 +203,7 @@ object Application { if ( target != this.target || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -327,7 +327,7 @@ object Application { if ( expression != this.expression || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -430,7 +430,7 @@ object Application { if ( items != this.items || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Case.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Case.scala index 244f7344f1d7..62b74e3f6e34 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Case.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Case.scala @@ -73,7 +73,7 @@ object Case { || branches != this.branches || isNested != this.isNested || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -200,7 +200,7 @@ object Case { || expression != this.expression || terminalBranch != this.terminalBranch || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Comment.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Comment.scala index af7bc15bab5b..aec36d55ac0e 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Comment.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Comment.scala @@ -62,7 +62,7 @@ object Comment { if ( doc != this.doc || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Error.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Error.scala index d298bce2a919..61cf402259ee 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Error.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Error.scala @@ -63,7 +63,7 @@ object Error { ): InvalidIR = { if ( ir != this.ir - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Foreign.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Foreign.scala index bbc88899bb28..0b5bbf151237 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Foreign.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Foreign.scala @@ -70,7 +70,7 @@ object Foreign { lang != this.lang || code != this.code || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Operator.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Operator.scala index 3a5027b7c05f..a9766a023e3f 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Operator.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Operator.scala @@ -72,7 +72,7 @@ object Operator { || operator != this.operator || right != this.right || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Section.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Section.scala index 1ab580d5c3c3..0e84be2aa3c6 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Section.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/Section.scala @@ -67,7 +67,7 @@ object Section { arg != this.arg || operator != this.operator || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -174,7 +174,7 @@ object Section { if ( operator != this.operator || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -277,7 +277,7 @@ object Section { operator != this.operator || arg != this.arg || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Conversion.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Conversion.scala index 276612dcf43b..d58369499372 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Conversion.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Conversion.scala @@ -55,7 +55,7 @@ sealed case class Conversion( if ( storedIr != this.storedIr || reason != this.reason - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/ImportExport.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/ImportExport.scala index 64f7c6d359bf..fb9c3ef98ed4 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/ImportExport.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/ImportExport.scala @@ -62,7 +62,7 @@ sealed case class ImportExport( if ( ir != this.ir || reason != this.reason - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Pattern.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Pattern.scala index 172c047e9823..2305cbe4bcaa 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Pattern.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Pattern.scala @@ -67,7 +67,7 @@ sealed case class Pattern( if ( originalPattern != this.originalPattern || reason != this.reason - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Redefined.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Redefined.scala index e375d7e1e179..69627bda0192 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Redefined.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Redefined.scala @@ -66,7 +66,7 @@ object Redefined { ): SelfArg = { if ( location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -161,7 +161,7 @@ object Redefined { targetType != this.targetType || sourceType != this.sourceType || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -291,7 +291,7 @@ object Redefined { typeName != this.typeName || methodName != this.methodName || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -421,7 +421,7 @@ object Redefined { atomName != this.atomName || methodName != this.methodName || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -544,7 +544,7 @@ object Redefined { if ( typeName != this.typeName || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -650,7 +650,7 @@ object Redefined { if ( name != this.name || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -751,7 +751,7 @@ object Redefined { ): Binding = { if ( invalidBinding != this.invalidBinding - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Resolution.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Resolution.scala index 269e241d2ecb..21c8d5c2f02f 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Resolution.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Resolution.scala @@ -71,7 +71,7 @@ sealed case class Resolution( if ( originalName != this.originalName || reason != this.reason - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Syntax.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Syntax.scala index a61fd2f53bc5..5398a563aaf5 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Syntax.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Syntax.scala @@ -63,7 +63,7 @@ sealed case class Syntax( if ( at != this.at || reason != this.reason - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Unexpected.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Unexpected.scala index 7b3a5a2e3db2..655db3f4ad23 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Unexpected.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/expression/errors/Unexpected.scala @@ -77,7 +77,7 @@ object Unexpected { ): TypeSignature = { if ( ir != this.ir - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Definition.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Definition.scala index 1eb7ed786660..df289a370d64 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Definition.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Definition.scala @@ -78,7 +78,7 @@ object Definition { || params != this.params || members != this.members || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -206,7 +206,7 @@ object Definition { || annotations != this.annotations || isPrivate != this.isPrivate || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -338,7 +338,7 @@ object Definition { || arguments != this.arguments || body != this.body || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Export.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Export.scala index aa289ba8ecb5..a845e03c426c 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Export.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Export.scala @@ -88,7 +88,7 @@ object Export { || onlyNames != this.onlyNames || isSynthetic != this.isSynthetic || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Import.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Import.scala index 754ee568a74a..da8ca4f59345 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Import.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/Import.scala @@ -97,7 +97,7 @@ object Import { || hiddenNames != this.hiddenNames || isSynthetic != this.isSynthetic || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/definition/Method.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/definition/Method.scala index 20a4feeab662..ecb23c8d42c7 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/definition/Method.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/definition/Method.scala @@ -115,7 +115,7 @@ object Method { || isPrivate != this.isPrivate || isStaticWrapperForInstanceMethod != this.isStaticWrapperForInstanceMethod || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -321,7 +321,7 @@ object Method { || isPrivate != this.isPrivate || body != this.body || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -493,7 +493,7 @@ object Method { || sourceTypeName != this.sourceTypeName || body != this.body || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/imports/Polyglot.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/imports/Polyglot.scala index 4a7484eaa0a7..3826e30d2e6c 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/imports/Polyglot.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/module/scope/imports/Polyglot.scala @@ -55,7 +55,7 @@ sealed case class Polyglot( entity != this.entity || rename != this.rename || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/type/Set.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/type/Set.scala index d40e3cf37dc7..2f3ffabf8327 100644 --- a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/type/Set.scala +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/type/Set.scala @@ -74,7 +74,7 @@ object Set { || memberType != this.memberType || value != this.value || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -202,7 +202,7 @@ object Set { left != this.left || right != this.right || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -315,7 +315,7 @@ object Set { left != this.left || right != this.right || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -428,7 +428,7 @@ object Set { left != this.left || right != this.right || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -535,7 +535,7 @@ object Set { if ( operands != this.operands || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { @@ -642,7 +642,7 @@ object Set { left != this.left || right != this.right || location != this.location - || passData != this.passData + || (passData ne this.passData) || diagnostics != this.diagnostics || id != this.id ) { diff --git a/engine/runtime-parser/src/test/java/org/enso/compiler/core/IrPersistanceTest.java b/engine/runtime-parser/src/test/java/org/enso/compiler/core/IrPersistanceTest.java index 1ee473a58de8..81b69719101c 100644 --- a/engine/runtime-parser/src/test/java/org/enso/compiler/core/IrPersistanceTest.java +++ b/engine/runtime-parser/src/test/java/org/enso/compiler/core/IrPersistanceTest.java @@ -419,9 +419,9 @@ public void nameLiteral() throws Exception { var loc = new IdentifiedLocation(new Location(5, 19), null); var in = new Name.Literal("anyName", true, loc, Option.empty(), new MetadataStorage()); - var out = serde(Name.Literal.class, in, 39); - assertEquals("They are structurally equal", 0, IR.STRUCTURE_COMPARATOR.compare(in, out)); - assertNotEquals("But not .equals (currently)", in, out); + var out = serde(Name.Literal.class, in, -1); + assertEquals("They are structurally equal", in, out); + assertNotSame("But not ==", in, out); } private static T serde(Class clazz, T l, int expectedSize) throws IOException { diff --git a/lib/java/persistance/src/main/java/org/enso/persist/PerInputImpl.java b/lib/java/persistance/src/main/java/org/enso/persist/PerInputImpl.java index 2df0d6113973..5785cfd65dd6 100644 --- a/lib/java/persistance/src/main/java/org/enso/persist/PerInputImpl.java +++ b/lib/java/persistance/src/main/java/org/enso/persist/PerInputImpl.java @@ -7,7 +7,6 @@ import java.io.DataInputStream; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -237,27 +236,9 @@ static Object readIndirect(InputCache cache, PerMap map, Input in) throws IOExce return res; } - private static Class irClass; - private static Comparator STRUCTURE_COMPARATOR; - @SuppressWarnings("unchecked") private static boolean gentlyEquals(Object o1, Object o2) { - if (Objects.equals(o1, o2)) { - return true; - } - try { - if (STRUCTURE_COMPARATOR == null) { - irClass = Class.forName("org.enso.compiler.core.IR"); - var comparatorField = irClass.getField("STRUCTURE_COMPARATOR"); - STRUCTURE_COMPARATOR = (java.util.Comparator) comparatorField.get(null); - } - if (irClass.isInstance(o1) && irClass.isInstance(o2)) { - return STRUCTURE_COMPARATOR.compare(o1, o2) == 0; - } - } catch (ReflectiveOperationException ex) { - PerUtils.LOG.warn("Cannot compare " + o1.getClass(), ex); - } - return false; + return Objects.equals(o1, o2); } private static void dumpObject(StringBuilder sb, Object obj) {