From 5b91f164985fcf98777015b1e7cd402054598a7a Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Fri, 12 Jan 2024 22:50:12 +0100 Subject: [PATCH] Generate UUIDs on demand (#8728) Trying to avoid expensive `UUID.randomUUID()` unless we reallly need it. Closes #8716. # Important Notes Some improvement: ![Screenshot from 2024-01-11 15-16-10](https://github.com/enso-org/enso/assets/292128/d8800490-6676-4b71-b178-7ce2e79942e5) FWIW Total Time for a Hello World example Before ![Screenshot from 2024-01-12 17-45-56](https://github.com/enso-org/enso/assets/292128/c0bfe7c5-c0a5-4375-8dd9-afb0714ae6c4) After ![Screenshot from 2024-01-12 17-46-13](https://github.com/enso-org/enso/assets/292128/ea76c413-018f-4b67-9777-85378eb38210) Memory usage Before ![Screenshot from 2024-01-12 17-54-54](https://github.com/enso-org/enso/assets/292128/280b1eff-e019-4241-a2a1-07445949d285) After ![Screenshot from 2024-01-12 17-54-36](https://github.com/enso-org/enso/assets/292128/b6524c8b-2a38-4e51-85eb-63142420f2ff) --- .../compiler/pass/analyse/AliasAnalysis.scala | 6 +- .../desugar/LambdaShorthandToLambda.scala | 3 +- .../enso/compiler/refactoring/IRUtils.scala | 2 +- .../instrument/job/EnsureCompiledJob.scala | 2 +- .../main/java/org/enso/compiler/core/IR.java | 7 +- .../enso/compiler/core/ir/CallArgument.scala | 7 +- .../compiler/core/ir/DefinitionArgument.scala | 7 +- .../org/enso/compiler/core/ir/Empty.scala | 7 +- .../enso/compiler/core/ir/Expression.scala | 15 +- .../org/enso/compiler/core/ir/Function.scala | 15 +- .../org/enso/compiler/core/ir/LazyId.scala | 26 +++ .../org/enso/compiler/core/ir/Literal.scala | 13 +- .../org/enso/compiler/core/ir/Module.scala | 7 +- .../org/enso/compiler/core/ir/Name.scala | 57 +++-- .../org/enso/compiler/core/ir/Pattern.scala | 31 ++- .../org/enso/compiler/core/ir/Type.scala | 25 ++- .../core/ir/expression/Application.scala | 25 ++- .../compiler/core/ir/expression/Case.scala | 14 +- .../compiler/core/ir/expression/Comment.scala | 7 +- .../compiler/core/ir/expression/Error.scala | 7 +- .../compiler/core/ir/expression/Foreign.scala | 7 +- .../core/ir/expression/Operator.scala | 7 +- .../compiler/core/ir/expression/Section.scala | 19 +- .../ir/expression/errors/Conversion.scala | 9 +- .../ir/expression/errors/ImportExport.scala | 7 +- .../core/ir/expression/errors/Pattern.scala | 8 +- .../core/ir/expression/errors/Redefined.scala | 43 ++-- .../ir/expression/errors/Resolution.scala | 9 +- .../core/ir/expression/errors/Syntax.scala | 7 +- .../ir/expression/errors/Unexpected.scala | 8 +- .../core/ir/module/scope/Definition.scala | 21 +- .../core/ir/module/scope/Export.scala | 8 +- .../core/ir/module/scope/Import.scala | 8 +- .../ir/module/scope/definition/Method.scala | 21 +- .../ir/module/scope/imports/Polyglot.scala | 8 +- .../org/enso/compiler/core/ir/type/Set.scala | 37 ++-- .../pass/analyse/DataflowAnalysisTest.scala | 204 +++++++++--------- .../pass/desugar/SectionsToBinOpTest.scala | 6 +- 38 files changed, 354 insertions(+), 366 deletions(-) create mode 100644 engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/LazyId.scala diff --git a/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/analyse/AliasAnalysis.scala b/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/analyse/AliasAnalysis.scala index 10dfd6896b0..276a9b1773f 100644 --- a/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/analyse/AliasAnalysis.scala +++ b/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/analyse/AliasAnalysis.scala @@ -413,7 +413,7 @@ case object AliasAnalysis extends IRPass { Occurrence.Def( occurrenceId, name.name, - binding.getId, + binding.getId(), binding.getExternalId, isSuspended ) @@ -525,7 +525,7 @@ case object AliasAnalysis extends IRPass { val definition = Graph.Occurrence.Def( occurrenceId, selfName.name, - arg.getId, + arg.getId(), arg.getExternalId ) scope.addDefinition(definition) @@ -557,7 +557,7 @@ case object AliasAnalysis extends IRPass { val definition = Graph.Occurrence.Def( occurrenceId, name.name, - arg.getId, + arg.getId(), arg.getExternalId, susp ) diff --git a/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/desugar/LambdaShorthandToLambda.scala b/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/desugar/LambdaShorthandToLambda.scala index 3fcf31efe95..40f22b53e1a 100644 --- a/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/desugar/LambdaShorthandToLambda.scala +++ b/engine/runtime-compiler/src/main/scala/org/enso/compiler/pass/desugar/LambdaShorthandToLambda.scala @@ -1,7 +1,6 @@ package org.enso.compiler.pass.desugar import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext} -import org.enso.compiler.core.IR import org.enso.compiler.core.ir.{ CallArgument, DefinitionArgument, @@ -412,7 +411,7 @@ case object LambdaShorthandToLambda extends IRPass { ) val lambdaArg = DefinitionArgument.Specified( - scrutineeName.copy(id = IR.randomId), + scrutineeName.copy(id = null), None, None, suspended = false, diff --git a/engine/runtime-compiler/src/main/scala/org/enso/compiler/refactoring/IRUtils.scala b/engine/runtime-compiler/src/main/scala/org/enso/compiler/refactoring/IRUtils.scala index a835c3dc3e3..9fb2fea5f87 100644 --- a/engine/runtime-compiler/src/main/scala/org/enso/compiler/refactoring/IRUtils.scala +++ b/engine/runtime-compiler/src/main/scala/org/enso/compiler/refactoring/IRUtils.scala @@ -88,7 +88,7 @@ trait IRUtils { for { metadata <- ir.getMetadata(DataflowAnalysis) key = DataflowAnalysis.DependencyInfo.Type - .Static(literal.getId, literal.getExternalId) + .Static(literal.getId(), literal.getExternalId) dependents <- metadata.dependents.get(key) } yield { dependents diff --git a/engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/EnsureCompiledJob.scala b/engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/EnsureCompiledJob.scala index c9338ed61c4..c085e7c5f81 100644 --- a/engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/EnsureCompiledJob.scala +++ b/engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/EnsureCompiledJob.scala @@ -384,7 +384,7 @@ final class EnsureCompiledJob( _ ) => DataflowAnalysis.DependencyInfo.Type.Static( - err.getId, + err.getId(), err.getExternalId ) } 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 66f1bed2e3a..ce6c27e615e 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 @@ -100,13 +100,8 @@ public interface IR extends Serializable { * * @return the node's identifier */ - default @Identifier UUID getId() { - return id(); - } - - /** A unique identifier for a piece of IR. */ @Identifier - UUID id(); + UUID getId(); /** Storage for compiler diagnostics related to the IR node. */ DiagnosticStorage diagnostics(); 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 589e39b5849..c0d0dd04f73 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 @@ -1,7 +1,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import java.util.UUID @@ -49,8 +48,8 @@ object CallArgument { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends CallArgument - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -110,7 +109,7 @@ object CallArgument { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 fef1e52ea46..0e5cb7cee82 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 @@ -2,7 +2,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID import scala.jdk.FunctionConverters.enrichAsScalaFromFunction @@ -64,8 +63,8 @@ object DefinitionArgument { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends DefinitionArgument - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -140,7 +139,7 @@ object DefinitionArgument { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 80da4597e07..48b69c1331c 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 @@ -2,7 +2,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -19,8 +18,8 @@ sealed case class Empty( ) extends IR with Expression with Diagnostic - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this` * @@ -54,7 +53,7 @@ sealed case class Empty( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 b9f7f8af6b0..0d3bd3ee706 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 @@ -3,7 +3,7 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.IR import org.enso.compiler.core.Identifier -import org.enso.compiler.core.IR.{indentLevel, mkIndent, randomId} +import org.enso.compiler.core.IR.{indentLevel, mkIndent} import java.util.UUID import scala.jdk.FunctionConverters.enrichAsScalaFromFunction @@ -63,8 +63,8 @@ object Expression { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Expression - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -125,7 +125,7 @@ object Expression { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -189,9 +189,8 @@ object Expression { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Expression - with IRKind.Primitive { - - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -241,7 +240,7 @@ object Expression { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 0e5ffc7b852..53ff71dcc7d 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 @@ -2,7 +2,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -51,7 +50,8 @@ object Function { passData: MetadataStorage, diagnostics: DiagnosticStorage ) extends Function - with IRKind.Primitive { + with IRKind.Primitive + with LazyId { def this( arguments: List[DefinitionArgument], body: Expression, @@ -62,8 +62,7 @@ object Function { ) = { this(arguments, Seq(body), location, canBeTCO, passData, diagnostics) } - var id: UUID @Identifier = randomId - override lazy val body = bodySeq.head + override lazy val body = bodySeq.head /** Creates a copy of `this`. * @@ -118,7 +117,7 @@ object Function { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -204,8 +203,8 @@ object Function { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Function - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -276,7 +275,7 @@ object Function { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ diff --git a/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/LazyId.scala b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/LazyId.scala new file mode 100644 index 00000000000..be0ed12ed2f --- /dev/null +++ b/engine/runtime-parser/src/main/scala/org/enso/compiler/core/ir/LazyId.scala @@ -0,0 +1,26 @@ +package org.enso.compiler.core.ir + +import org.enso.compiler.core.IR.randomId +import org.enso.compiler.core.{IR, Identifier} + +import java.util.UUID + +trait LazyId { self: IR => + private[this] var _id: UUID @Identifier = null + + protected def id: UUID @Identifier = { + _id + } + + override def getId(): UUID @Identifier = { + if (_id == null) { + _id = randomId() + } + _id + } + + def id_=(id: UUID @Identifier) = { + assert(_id == null) + _id = 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 0adb0a71f2f..d935160acc1 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 @@ -2,7 +2,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{CompilerError, IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -42,8 +41,8 @@ object Literal { location: Option[IdentifiedLocation], passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Literal { - var id: UUID @Identifier = randomId + ) extends Literal + with LazyId { /** Creates a copy of `this`. * @@ -81,7 +80,7 @@ object Literal { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -169,8 +168,8 @@ object Literal { location: Option[IdentifiedLocation], passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Literal { - var id: UUID @Identifier = randomId + ) extends Literal + with LazyId { /** Creates a copy of `this`. * @@ -206,7 +205,7 @@ object Literal { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 316f00438e2..ffcd2b062c9 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 @@ -1,7 +1,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.ir.module.scope.{Definition, Export, Import} @@ -32,8 +31,8 @@ final case class Module( passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends IR - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -98,7 +97,7 @@ final case class Module( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 c7ad3005718..61ef306d6a0 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 @@ -1,7 +1,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.{ConstantsNames, IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import java.util.UUID @@ -51,10 +50,10 @@ object Name { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Name - with IRKind.Sugar { + with IRKind.Sugar + with LazyId { override val name: String = showCode() - var id: UUID @Identifier = randomId /** Creates a copy of `this`. * @@ -113,7 +112,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -212,7 +211,8 @@ object Name { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Name - with IRKind.Primitive { + with IRKind.Primitive + with LazyId { override val name: String = parts.map(_.name).mkString(".") @@ -271,15 +271,12 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ override def children: List[IR] = parts - /** @inheritdoc */ - var id: UUID @Identifier = randomId - /** @inheritdoc */ override def showCode(indent: Int): String = name } @@ -295,9 +292,9 @@ object Name { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Name - with IRKind.Sugar { + with IRKind.Sugar + with LazyId { override val name: String = "_" - var id: UUID @Identifier = randomId /** Creates a copy of `this`. * @@ -331,7 +328,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -368,9 +365,9 @@ object Name { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Name - with IRKind.Sugar { + with IRKind.Sugar + with LazyId { override val name: String = s"" - var id: UUID @Identifier = randomId /** Creates a copy of `this`. * @@ -404,7 +401,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) override def mapExpressions( @@ -461,8 +458,8 @@ object Name { originalName: Option[Name] = None, passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Name { - var id: UUID @Identifier = randomId + ) extends Name + with LazyId { /** Creates a copy of `this`. * @@ -503,7 +500,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -568,8 +565,8 @@ object Name { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Annotation - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -605,7 +602,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -653,8 +650,8 @@ object Name { location: Option[IdentifiedLocation], passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Annotation { - var id: UUID @Identifier = randomId + ) extends Annotation + with LazyId { /** Creates a copy of `this`. * @@ -693,7 +690,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -740,8 +737,8 @@ object Name { synthetic: Boolean = false, passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Name { - var id: UUID @Identifier = randomId + ) extends Name + with LazyId { override val name: String = ConstantsNames.SELF_ARGUMENT /** Creates a copy of `self`. @@ -777,7 +774,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -818,8 +815,8 @@ object Name { location: Option[IdentifiedLocation], passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Name { - var id: UUID @Identifier = randomId + ) extends Name + with LazyId { override val name: String = ConstantsNames.SELF_TYPE_ARGUMENT /** Creates a copy of `Self`. @@ -854,7 +851,7 @@ object Name { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 e551a456b0d..352390e7292 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 @@ -3,7 +3,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.{CompilerError, IR, Identifier} import org.enso.compiler.core.ir.{Literal => IRLiteral, Name => IRName} import org.enso.compiler.core.ir.expression.errors -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import java.util.UUID @@ -46,8 +45,8 @@ object Pattern { override val location: Option[IdentifiedLocation], override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Pattern { - var id: UUID @Identifier = randomId + ) extends Pattern + with LazyId { /** Creates a copy of `this`. * @@ -89,7 +88,7 @@ object Pattern { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -139,8 +138,8 @@ object Pattern { override val location: Option[IdentifiedLocation], override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Pattern { - var id: UUID @Identifier = randomId + ) extends Pattern + with LazyId { /** Creates a copy of `this`. * @@ -193,7 +192,7 @@ object Pattern { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** Checks if the constructor pattern has been desugared. @@ -290,8 +289,8 @@ object Pattern { override val location: Option[IdentifiedLocation], override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Pattern { - var id: UUID @Identifier = randomId + ) extends Pattern + with LazyId { /** Creates a copy of `this`. * @@ -333,7 +332,7 @@ object Pattern { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -385,8 +384,8 @@ object Pattern { override val location: Option[IdentifiedLocation], override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Pattern { - var id: UUID @Identifier = randomId + ) extends Pattern + with LazyId { /** Creates a copy of `this`. * @@ -436,7 +435,7 @@ object Pattern { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -488,8 +487,8 @@ object Pattern { override val location: Option[IdentifiedLocation], override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Pattern { - var id: UUID @Identifier = randomId + ) extends Pattern + with LazyId { /** @inheritdoc */ override def mapExpressions( @@ -538,7 +537,7 @@ object Pattern { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 28c94690e48..7224d004efb 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 @@ -2,7 +2,6 @@ package org.enso.compiler.core.ir import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID import scala.jdk.FunctionConverters.enrichAsScalaFromFunction @@ -40,8 +39,8 @@ object Type { override val location: Option[IdentifiedLocation], override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() - ) extends Type { - var id: UUID @Identifier = randomId + ) extends Type + with LazyId { def copy( args: List[Expression] = args, @@ -83,7 +82,7 @@ object Type { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -136,8 +135,8 @@ object Type { override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Type with module.scope.Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -190,7 +189,7 @@ object Type { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -246,8 +245,8 @@ object Type { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Type - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates ac opy of `this`. * @@ -297,7 +296,7 @@ object Type { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -350,8 +349,8 @@ object Type { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Type - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -401,7 +400,7 @@ object Type { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 523dfcac460..969e1035b6a 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 @@ -3,7 +3,6 @@ package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID import scala.jdk.FunctionConverters.enrichAsScalaFromFunction @@ -31,8 +30,8 @@ object Application { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Application - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -95,7 +94,7 @@ object Application { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -147,8 +146,8 @@ object Application { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Application - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -190,7 +189,7 @@ object Application { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -259,8 +258,8 @@ object Application { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Literal - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { override def mapExpressions( fn: java.util.function.Function[Expression, Expression] @@ -309,7 +308,7 @@ object Application { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -355,8 +354,8 @@ object Application { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Literal - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { override def mapExpressions( fn: java.util.function.Function[Expression, Expression] @@ -405,7 +404,7 @@ object Application { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 543ad2823c5..40c89adee52 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 @@ -3,7 +3,7 @@ package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.{indentLevel, mkIndent, randomId} +import org.enso.compiler.core.IR.{indentLevel, mkIndent} import java.util.UUID @@ -46,8 +46,8 @@ object Case { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Case - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { def this( scrutinee: Expression, @@ -113,7 +113,7 @@ object Case { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -199,8 +199,8 @@ object Case { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Case - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { def this( pattern: Pattern, @@ -269,7 +269,7 @@ object Case { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 63cad7793a5..45d0a500cd7 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 @@ -3,7 +3,6 @@ package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -42,8 +41,8 @@ object Comment { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Comment - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -79,7 +78,7 @@ object Comment { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 22e623f6d91..f4ba6a5a324 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 @@ -2,7 +2,6 @@ package org.enso.compiler.core.ir package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.ir.Expression import org.enso.compiler.core.{ir, IR, Identifier} @@ -42,8 +41,8 @@ object Error { override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Error with Diagnostic.Kind.Static - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -82,7 +81,7 @@ object Error { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 6b972830ead..410c407cb35 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 @@ -3,7 +3,6 @@ package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.ir.MetadataStorage import java.util.UUID @@ -47,8 +46,8 @@ object Foreign { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Foreign - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -86,7 +85,7 @@ object Foreign { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 c64d0b5f764..4d0f364f1de 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 @@ -3,7 +3,6 @@ package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID; @@ -46,8 +45,8 @@ object Operator { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Operator - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -106,7 +105,7 @@ object Operator { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 cc398430cbf..cfcfb3c171d 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 @@ -3,7 +3,6 @@ package expression import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -44,8 +43,8 @@ object Section { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Section - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -96,7 +95,7 @@ object Section { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -146,8 +145,8 @@ object Section { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Section - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -190,7 +189,7 @@ object Section { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -239,8 +238,8 @@ object Section { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Section - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -291,7 +290,7 @@ object Section { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 8af758a61e8..91f9737db1e 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 @@ -3,7 +3,6 @@ package expression package errors import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -22,7 +21,8 @@ sealed case class Conversion( ) extends Error with Diagnostic.Kind.Interactive with IRKind.Primitive - with Name { + with Name + with LazyId { override val name: String = "conversion_error" override def mapExpressions( @@ -75,16 +75,13 @@ sealed case class Conversion( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) } /** @inheritdoc */ override def children: List[IR] = List(storedIr) - /** @inheritdoc */ - var id: UUID @Identifier = randomId - /** @inheritdoc */ override def showCode(indent: Int): String = s"(Error: ${storedIr.showCode(indent)})" 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 28ab209bee5..67fb08f8c05 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 @@ -4,7 +4,6 @@ package errors import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID import scala.annotation.unused @@ -25,8 +24,8 @@ sealed case class ImportExport( with Diagnostic.Kind.Interactive with org.enso.compiler.core.ir.module.scope.Import with org.enso.compiler.core.ir.module.scope.Export - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -61,7 +60,7 @@ sealed case class ImportExport( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 e0fefda1842..a840f1b4249 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 @@ -3,7 +3,6 @@ package expression package errors import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -22,7 +21,8 @@ sealed case class Pattern( diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Error with Diagnostic.Kind.Interactive - with org.enso.compiler.core.ir.Pattern { + with org.enso.compiler.core.ir.Pattern + with LazyId { override def mapExpressions( fn: java.util.function.Function[Expression, Expression] ): Pattern = @@ -71,7 +71,7 @@ sealed case class Pattern( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) override def message(source: (IdentifiedLocation => String)): String = @@ -84,8 +84,6 @@ sealed case class Pattern( override def children: List[IR] = List(originalPattern) - var id: UUID @Identifier = randomId - override def showCode(indent: Int): String = originalPattern.showCode(indent) } 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 d1176d174f5..ebb169ac199 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 @@ -4,7 +4,6 @@ package errors import org.enso.compiler.core.Implicits.ShowPassData import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -45,8 +44,8 @@ object Redefined { override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Redefined with Diagnostic.Kind.Interactive - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `self`. * @@ -80,7 +79,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -128,8 +127,8 @@ object Redefined { ) extends Redefined with Diagnostic.Kind.Interactive with module.scope.Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -185,7 +184,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -253,8 +252,8 @@ object Redefined { ) extends Redefined with Diagnostic.Kind.Interactive with module.scope.Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -309,7 +308,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -377,8 +376,8 @@ object Redefined { ) extends Redefined with Diagnostic.Kind.Interactive with module.scope.Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -436,7 +435,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -496,8 +495,8 @@ object Redefined { ) extends Redefined with Diagnostic.Kind.Interactive with module.scope.Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -542,7 +541,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -597,8 +596,8 @@ object Redefined { ) extends Redefined with Diagnostic.Kind.Interactive with module.scope.Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -643,7 +642,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -697,8 +696,8 @@ object Redefined { override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Redefined with Diagnostic.Kind.Interactive - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -738,7 +737,7 @@ object Redefined { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 1dd8dbad4db..3d0303b3a30 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 @@ -3,7 +3,6 @@ package expression package errors import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -22,7 +21,8 @@ sealed case class Resolution( ) extends Error with Diagnostic.Kind.Interactive with IRKind.Primitive - with Name { + with Name + with LazyId { override val name: String = originalName.name override def mapExpressions( @@ -75,15 +75,12 @@ sealed case class Resolution( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ override def children: List[IR] = List(originalName) - /** @inheritdoc */ - var id: UUID @Identifier = randomId - /** @inheritdoc */ override def showCode(indent: Int): String = originalName.showCode(indent) 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 8aead0b28e0..f4769169f29 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 @@ -4,7 +4,6 @@ package errors import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID import scala.annotation.unused @@ -26,8 +25,8 @@ sealed case class Syntax( with module.scope.Definition with module.scope.Export with module.scope.Import - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -62,7 +61,7 @@ sealed case class Syntax( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 979e3a6b6b6..35e29bbcfa7 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 @@ -3,7 +3,6 @@ package expression package errors import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -57,11 +56,10 @@ object Unexpected { diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Unexpected with IRKind.Primitive - with org.enso.compiler.core.ir.module.scope.Definition { + with org.enso.compiler.core.ir.module.scope.Definition + with LazyId { override val entity: String = "type signature" - var id: UUID @Identifier = randomId - /** Creates a copy of `this`. * * @param ir the erroneous signature @@ -109,7 +107,7 @@ object Unexpected { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 6846081aa2d..d17db236a70 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 @@ -7,12 +7,13 @@ import org.enso.compiler.core.ir.{ Expression, IRKind, IdentifiedLocation, + LazyId, MetadataStorage, Name } import org.enso.compiler.core.ir.module.Scope import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} -import org.enso.compiler.core.IR.{indentLevel, mkIndent, randomId} +import org.enso.compiler.core.IR.{indentLevel, mkIndent} import java.util.UUID @@ -60,8 +61,8 @@ object Definition { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Definition - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { def copy( name: Name = name, @@ -105,7 +106,7 @@ object Definition { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -165,8 +166,8 @@ object Definition { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends IR - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -227,7 +228,7 @@ object Definition { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -288,8 +289,8 @@ object Definition { passData: MetadataStorage = new MetadataStorage(), diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Definition - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -358,7 +359,7 @@ object Definition { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 b0b049ed009..9408ee8e78b 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 @@ -2,13 +2,13 @@ package org.enso.compiler.core.ir.module.scope import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.ir.module.Scope import org.enso.compiler.core.ir.{ DiagnosticStorage, Expression, IRKind, IdentifiedLocation, + LazyId, MetadataStorage, Name } @@ -61,8 +61,8 @@ object Export { override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends IR with IRKind.Primitive - with Export { - var id: UUID @Identifier = randomId + with Export + with LazyId { /** Creates a copy of `this`. * @@ -118,7 +118,7 @@ object Export { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 fccdb58bf13..e22ebb096db 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 @@ -2,13 +2,13 @@ package org.enso.compiler.core.ir.module.scope import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.ir.module.Scope import org.enso.compiler.core.ir.{ DiagnosticStorage, Expression, IRKind, IdentifiedLocation, + LazyId, MetadataStorage, Name } @@ -60,8 +60,8 @@ object Import { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Import - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -133,7 +133,7 @@ object Import { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 5b7c5158350..cd6efdd945c 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 @@ -5,7 +5,6 @@ package definition import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import java.util.UUID @@ -56,7 +55,8 @@ object Method { override val passData: MetadataStorage, override val diagnostics: DiagnosticStorage ) extends Method - with IRKind.Primitive { + with IRKind.Primitive + with LazyId { def this( methodReference: Name.MethodReference, body: Expression, @@ -75,8 +75,7 @@ object Method { ); } - var id: UUID @Identifier = randomId - lazy val body = bodySeq.head + lazy val body = bodySeq.head /** Creates a copy of `this`. * @@ -138,7 +137,7 @@ object Method { diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -242,8 +241,8 @@ object Method { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Method - with IRKind.Sugar { - var id: UUID @Identifier = randomId + with IRKind.Sugar + with LazyId { /** Creates a copy of `this`. * @@ -311,7 +310,7 @@ object Method { diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -382,8 +381,8 @@ object Method { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Method - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -451,7 +450,7 @@ object Method { diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) } 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 7e6bbd0be25..8b89a328a2d 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 @@ -2,13 +2,13 @@ package org.enso.compiler.core.ir.module.scope.imports import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.ir.module.scope.Import import org.enso.compiler.core.ir.{ DiagnosticStorage, Expression, IRKind, IdentifiedLocation, + LazyId, MetadataStorage } @@ -30,8 +30,8 @@ sealed case class Polyglot( override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Import - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -71,7 +71,7 @@ sealed case class Polyglot( if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ 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 cecfeca9556..817b00cf7c9 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 @@ -3,7 +3,6 @@ package `type` import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper} import org.enso.compiler.core.{IR, Identifier} -import org.enso.compiler.core.IR.randomId import org.enso.compiler.core.ir.Type.Info import java.util.UUID @@ -48,8 +47,8 @@ object Set { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Set - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -109,7 +108,7 @@ object Set { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -171,8 +170,8 @@ object Set { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Set - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -222,7 +221,7 @@ object Set { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -276,8 +275,8 @@ object Set { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Set - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -327,7 +326,7 @@ object Set { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -381,8 +380,8 @@ object Set { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Set - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -432,7 +431,7 @@ object Set { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -483,8 +482,8 @@ object Set { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Set - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -529,7 +528,7 @@ object Set { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ @@ -581,8 +580,8 @@ object Set { override val passData: MetadataStorage = new MetadataStorage(), override val diagnostics: DiagnosticStorage = DiagnosticStorage() ) extends Set - with IRKind.Primitive { - var id: UUID @Identifier = randomId + with IRKind.Primitive + with LazyId { /** Creates a copy of `this`. * @@ -632,7 +631,7 @@ object Set { if (keepMetadata) passData.duplicate else new MetadataStorage(), diagnostics = if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(), - id = if (keepIdentifiers) id else randomId + id = if (keepIdentifiers) id else null ) /** @inheritdoc */ diff --git a/engine/runtime/src/test/scala/org/enso/compiler/test/pass/analyse/DataflowAnalysisTest.scala b/engine/runtime/src/test/scala/org/enso/compiler/test/pass/analyse/DataflowAnalysisTest.scala index 943e2501ff4..48a1ecf7369 100644 --- a/engine/runtime/src/test/scala/org/enso/compiler/test/pass/analyse/DataflowAnalysisTest.scala +++ b/engine/runtime/src/test/scala/org/enso/compiler/test/pass/analyse/DataflowAnalysisTest.scala @@ -356,31 +356,31 @@ class DataflowAnalysisTest extends CompilerTest { val plusSymbol = mkDynamicDep("+") // The Identifiers - val methodId = mkStaticDep(method.getId) - val fnId = mkStaticDep(fn.getId) - val fnArgAId = mkStaticDep(fnArgA.getId) - val fnArgBId = mkStaticDep(fnArgB.getId) - val fnBodyId = mkStaticDep(fnBody.getId) - val printlnExprId = mkStaticDep(printlnExpr.getId) - val printlnFnId = mkStaticDep(printlnFn.getId) - val printlnArgIOId = mkStaticDep(printlnArgIO.getId) - val printlnArgIOExprId = mkStaticDep(printlnArgIOExpr.getId) - val printlnArgBId = mkStaticDep(printlnArgB.getId) - val printlnArgBExprId = mkStaticDep(printlnArgBExpr.getId) - val cBindExprId = mkStaticDep(cBindExpr.getId) - val cBindNameId = mkStaticDep(cBindName.getId) - val plusExprId = mkStaticDep(plusExpr.getId) - val plusExprFnId = mkStaticDep(plusExprFn.getId) - val plusExprArgAId = mkStaticDep(plusExprArgA.getId) - val plusExprArgAExprId = mkStaticDep(plusExprArgAExpr.getId) - val plusExprArgBId = mkStaticDep(plusExprArgB.getId) - val plusExprArgBExprId = mkStaticDep(plusExprArgBExpr.getId) - val frobExprId = mkStaticDep(frobExpr.getId) - val frobFnId = mkStaticDep(frobFn.getId) - val frobArgAId = mkStaticDep(frobArgA.getId) - val frobArgAExprId = mkStaticDep(frobArgAExpr.getId) - val frobArgCId = mkStaticDep(frobArgC.getId) - val frobArgCExprId = mkStaticDep(frobArgCExpr.getId) + val methodId = mkStaticDep(method.getId()) + val fnId = mkStaticDep(fn.getId()) + val fnArgAId = mkStaticDep(fnArgA.getId()) + val fnArgBId = mkStaticDep(fnArgB.getId()) + val fnBodyId = mkStaticDep(fnBody.getId()) + val printlnExprId = mkStaticDep(printlnExpr.getId()) + val printlnFnId = mkStaticDep(printlnFn.getId()) + val printlnArgIOId = mkStaticDep(printlnArgIO.getId()) + val printlnArgIOExprId = mkStaticDep(printlnArgIOExpr.getId()) + val printlnArgBId = mkStaticDep(printlnArgB.getId()) + val printlnArgBExprId = mkStaticDep(printlnArgBExpr.getId()) + val cBindExprId = mkStaticDep(cBindExpr.getId()) + val cBindNameId = mkStaticDep(cBindName.getId()) + val plusExprId = mkStaticDep(plusExpr.getId()) + val plusExprFnId = mkStaticDep(plusExprFn.getId()) + val plusExprArgAId = mkStaticDep(plusExprArgA.getId()) + val plusExprArgAExprId = mkStaticDep(plusExprArgAExpr.getId()) + val plusExprArgBId = mkStaticDep(plusExprArgB.getId()) + val plusExprArgBExprId = mkStaticDep(plusExprArgBExpr.getId()) + val frobExprId = mkStaticDep(frobExpr.getId()) + val frobFnId = mkStaticDep(frobFn.getId()) + val frobArgAId = mkStaticDep(frobArgA.getId()) + val frobArgAExprId = mkStaticDep(frobArgAExpr.getId()) + val frobArgCId = mkStaticDep(frobArgC.getId()) + val frobArgCExprId = mkStaticDep(frobArgCExpr.getId()) "correctly identify global symbol direct dependents" in { depInfo.dependents.getDirect(frobnicateSymbol) shouldEqual Some( @@ -960,15 +960,15 @@ class DataflowAnalysisTest extends CompilerTest { val plusArgYExpr = plusArgY.value.asInstanceOf[Name.Literal] // Identifiers - val fnId = mkStaticDep(fn.getId) - val fnArgXId = mkStaticDep(fnArgX.getId) - val fnArgYId = mkStaticDep(fnArgY.getId) - val fnBodyId = mkStaticDep(fnBody.getId) - val plusFnId = mkStaticDep(plusFn.getId) - val plusArgXId = mkStaticDep(plusArgX.getId) - val plusArgXExprId = mkStaticDep(plusArgXExpr.getId) - val plusArgYId = mkStaticDep(plusArgY.getId) - val plusArgYExprId = mkStaticDep(plusArgYExpr.getId) + val fnId = mkStaticDep(fn.getId()) + val fnArgXId = mkStaticDep(fnArgX.getId()) + val fnArgYId = mkStaticDep(fnArgY.getId()) + val fnBodyId = mkStaticDep(fnBody.getId()) + val plusFnId = mkStaticDep(plusFn.getId()) + val plusArgXId = mkStaticDep(plusArgX.getId()) + val plusArgXExprId = mkStaticDep(plusArgXExpr.getId()) + val plusArgYId = mkStaticDep(plusArgY.getId()) + val plusArgYExprId = mkStaticDep(plusArgYExpr.getId()) // Dynamic Symbols val plusSym = mkDynamicDep("+") @@ -1029,20 +1029,20 @@ class DataflowAnalysisTest extends CompilerTest { val mulArg2Expr = mulArg2.value.asInstanceOf[Name.Literal] // Identifiers - val appId = mkStaticDep(app.getId) - val appFnId = mkStaticDep(appFn.getId) - val appArg10Id = mkStaticDep(appArg10.getId) - val appArg10ExprId = mkStaticDep(appArg10Expr.getId) - val appArg10NameId = mkStaticDep(appArg10Name.getId) - val appArgFnId = mkStaticDep(appArgFn.getId) - val lamId = mkStaticDep(lam.getId) - val lamArgXId = mkStaticDep(lamArgX.getId) - val mulId = mkStaticDep(mul.getId) - val mulFnId = mkStaticDep(mulFn.getId) - val mulArg1Id = mkStaticDep(mulArg1.getId) - val mulArg1ExprId = mkStaticDep(mulArg1Expr.getId) - val mulArg2Id = mkStaticDep(mulArg2.getId) - val mulArg2ExprId = mkStaticDep(mulArg2Expr.getId) + val appId = mkStaticDep(app.getId()) + val appFnId = mkStaticDep(appFn.getId()) + val appArg10Id = mkStaticDep(appArg10.getId()) + val appArg10ExprId = mkStaticDep(appArg10Expr.getId()) + val appArg10NameId = mkStaticDep(appArg10Name.getId()) + val appArgFnId = mkStaticDep(appArgFn.getId()) + val lamId = mkStaticDep(lam.getId()) + val lamArgXId = mkStaticDep(lamArgX.getId()) + val mulId = mkStaticDep(mul.getId()) + val mulFnId = mkStaticDep(mulFn.getId()) + val mulArg1Id = mkStaticDep(mulArg1.getId()) + val mulArg1ExprId = mkStaticDep(mulArg1Expr.getId()) + val mulArg2Id = mkStaticDep(mulArg2.getId()) + val mulArg2ExprId = mkStaticDep(mulArg2Expr.getId()) // Global Symbols val mulSym = mkDynamicDep("*") @@ -1108,7 +1108,7 @@ class DataflowAnalysisTest extends CompilerTest { lam.arguments.head.asInstanceOf[DefinitionArgument.Specified] // The IDs - val argXId = mkStaticDep(argX.getId) + val argXId = mkStaticDep(argX.getId()) // The info val dependencies = depInfo.dependencies @@ -1134,10 +1134,10 @@ class DataflowAnalysisTest extends CompilerTest { val xBindExpr = xBind.expression.asInstanceOf[Literal.Number] // The IDs - val blockId = mkStaticDep(block.getId) - val xBindId = mkStaticDep(xBind.getId) - val xBindNameId = mkStaticDep(xBindName.getId) - val xBindExprId = mkStaticDep(xBindExpr.getId) + val blockId = mkStaticDep(block.getId()) + val xBindId = mkStaticDep(xBind.getId()) + val xBindNameId = mkStaticDep(xBindName.getId()) + val xBindExprId = mkStaticDep(xBindExpr.getId()) // The info val dependents = depInfo.dependents @@ -1171,9 +1171,9 @@ class DataflowAnalysisTest extends CompilerTest { val bindingExpr = binding.expression.asInstanceOf[Literal.Number] // The IDs - val bindingId = mkStaticDep(binding.getId) - val bindingNameId = mkStaticDep(bindingName.getId) - val bindingExprId = mkStaticDep(bindingExpr.getId) + val bindingId = mkStaticDep(binding.getId()) + val bindingNameId = mkStaticDep(bindingName.getId()) + val bindingExprId = mkStaticDep(bindingExpr.getId()) // The info val dependents = depInfo.dependents @@ -1217,14 +1217,14 @@ class DataflowAnalysisTest extends CompilerTest { val undefinedName = undefinedExpr.originalName // The IDs - val bindingId = mkStaticDep(binding.getId) - val bindingExprId = mkStaticDep(bindingExpr.getId) - val bindingNameId = mkStaticDep(bindingName.getId) - val plusFnId = mkStaticDep(plusFn.getId) - val numArgId = mkStaticDep(numArg.getId) - val numArgExprId = mkStaticDep(numArgExpr.getId) - val undefinedArgId = mkStaticDep(undefinedArg.getId) - val undefinedExprId = mkStaticDep(undefinedExpr.getId) + val bindingId = mkStaticDep(binding.getId()) + val bindingExprId = mkStaticDep(bindingExpr.getId()) + val bindingNameId = mkStaticDep(bindingName.getId()) + val plusFnId = mkStaticDep(plusFn.getId()) + val numArgId = mkStaticDep(numArg.getId()) + val numArgExprId = mkStaticDep(numArgExpr.getId()) + val undefinedArgId = mkStaticDep(undefinedArg.getId()) + val undefinedExprId = mkStaticDep(undefinedExpr.getId()) val undefinedSym = mkDynamicDep(undefinedName.name) val plusSym = mkDynamicDep("+") @@ -1277,12 +1277,12 @@ class DataflowAnalysisTest extends CompilerTest { val vector = ir.body .asInstanceOf[Application.Sequence] - val xUseId = mkStaticDep(vector.items(0).getId) - val yId = mkStaticDep(vector.items(1).getId) - val litId = mkStaticDep(vector.items(2).getId) - val vecId = mkStaticDep(vector.getId) - val appId = mkStaticDep(ir.body.getId) - val lamId = mkStaticDep(ir.getId) + val xUseId = mkStaticDep(vector.items(0).getId()) + val yId = mkStaticDep(vector.items(1).getId()) + val litId = mkStaticDep(vector.items(2).getId()) + val vecId = mkStaticDep(vector.getId()) + val appId = mkStaticDep(ir.body.getId()) + val lamId = mkStaticDep(ir.getId()) // The info val dependents = depInfo.dependents @@ -1313,8 +1313,8 @@ class DataflowAnalysisTest extends CompilerTest { val literal = ir.asInstanceOf[Application.Typeset] val literalExpression = literal.expression.get - val literalId = mkStaticDep(literal.getId) - val literalExpressionId = mkStaticDep(literalExpression.getId) + val literalId = mkStaticDep(literal.getId()) + val literalExpressionId = mkStaticDep(literalExpression.getId()) depInfo.dependents.getDirect(literalExpressionId).get shouldEqual Set( literalId @@ -1369,26 +1369,26 @@ class DataflowAnalysisTest extends CompilerTest { val plusSym = mkDynamicDep("+") // The IDs - val caseBlockId = mkStaticDep(caseBlock.getId) - val caseBindingId = mkStaticDep(caseBinding.getId) - val caseBindingExprId = mkStaticDep(caseBindingExpr.getId) - val caseBindingNameId = mkStaticDep(caseBindingName.getId) - val caseExprId = mkStaticDep(caseExpr.getId) - val consBranchId = mkStaticDep(consBranch.getId) + val caseBlockId = mkStaticDep(caseBlock.getId()) + val caseBindingId = mkStaticDep(caseBinding.getId()) + val caseBindingExprId = mkStaticDep(caseBindingExpr.getId()) + val caseBindingNameId = mkStaticDep(caseBindingName.getId()) + val caseExprId = mkStaticDep(caseExpr.getId()) + val consBranchId = mkStaticDep(consBranch.getId()) - val consBranchPatternId = mkStaticDep(consBranchPattern.getId) - val consBranchPatternConsId = mkStaticDep(consBranchPatternCons.getId) - val consBranchAPatternId = mkStaticDep(consBranchAPattern.getId) - val consBranchADefId = mkStaticDep(consBranchADef.getId) - val consBranchBPatternId = mkStaticDep(consBranchBPattern.getId) - val consBranchBDefId = mkStaticDep(consBranchBDef.getId) + val consBranchPatternId = mkStaticDep(consBranchPattern.getId()) + val consBranchPatternConsId = mkStaticDep(consBranchPatternCons.getId()) + val consBranchAPatternId = mkStaticDep(consBranchAPattern.getId()) + val consBranchADefId = mkStaticDep(consBranchADef.getId()) + val consBranchBPatternId = mkStaticDep(consBranchBPattern.getId()) + val consBranchBDefId = mkStaticDep(consBranchBDef.getId()) - val consBranchExpressionId = mkStaticDep(consBranchExpression.getId) - val consBranchFnId = mkStaticDep(consBranchFn.getId) - val aArgId = mkStaticDep(aArg.getId) - val aUseId = mkStaticDep(aUse.getId) - val bArgId = mkStaticDep(bArg.getId) - val bUseId = mkStaticDep(bUse.getId) + val consBranchExpressionId = mkStaticDep(consBranchExpression.getId()) + val consBranchFnId = mkStaticDep(consBranchFn.getId()) + val aArgId = mkStaticDep(aArg.getId()) + val aUseId = mkStaticDep(aUse.getId()) + val bArgId = mkStaticDep(bArg.getId()) + val bUseId = mkStaticDep(bUse.getId()) // The info val dependents = depInfo.dependents @@ -1567,18 +1567,18 @@ class DataflowAnalysisTest extends CompilerTest { val fooSymbol = mkDynamicDep("Foo") // The identifiers - val conversionId = mkStaticDep(conversion.getId) - val sourceTypeId = mkStaticDep(sourceType.getId) - val lambdaId = mkStaticDep(lambda.getId) - val fnArgThisId = mkStaticDep(fnArgThis.getId) - val fnArgValueId = mkStaticDep(fnArgValue.getId) - val fnBodyId = mkStaticDep(fnBody.getId) - val fooExprId = mkStaticDep(fooExpr.getId) - val fooFunctionId = mkStaticDep(fooFunction.getId) - val fooArg1Id = mkStaticDep(fooArg1.getId) - val fooArg1ExprId = mkStaticDep(fooArg1Expr.getId) - val fooArg2Id = mkStaticDep(fooArg2.getId) - val fooArg2ExprId = mkStaticDep(fooArg2Expr.getId) + val conversionId = mkStaticDep(conversion.getId()) + val sourceTypeId = mkStaticDep(sourceType.getId()) + val lambdaId = mkStaticDep(lambda.getId()) + val fnArgThisId = mkStaticDep(fnArgThis.getId()) + val fnArgValueId = mkStaticDep(fnArgValue.getId()) + val fnBodyId = mkStaticDep(fnBody.getId()) + val fooExprId = mkStaticDep(fooExpr.getId()) + val fooFunctionId = mkStaticDep(fooFunction.getId()) + val fooArg1Id = mkStaticDep(fooArg1.getId()) + val fooArg1ExprId = mkStaticDep(fooArg1Expr.getId()) + val fooArg2Id = mkStaticDep(fooArg2.getId()) + val fooArg2ExprId = mkStaticDep(fooArg2Expr.getId()) // The info val dependents = depInfo.dependents diff --git a/engine/runtime/src/test/scala/org/enso/compiler/test/pass/desugar/SectionsToBinOpTest.scala b/engine/runtime/src/test/scala/org/enso/compiler/test/pass/desugar/SectionsToBinOpTest.scala index a50c98acc93..e4d68e9a5fe 100644 --- a/engine/runtime/src/test/scala/org/enso/compiler/test/pass/desugar/SectionsToBinOpTest.scala +++ b/engine/runtime/src/test/scala/org/enso/compiler/test/pass/desugar/SectionsToBinOpTest.scala @@ -118,8 +118,8 @@ class SectionsToBinOpTest extends CompilerTest { lamBodyFirstArg.name shouldEqual leftLamArgName.name lamBodySecondArg.name shouldEqual rightLamArgName.name - lamBodyFirstArg.getId should not equal leftLamArgName.getId - lamBodySecondArg.getId should not equal rightLamArgName.getId + lamBodyFirstArg.getId() should not equal leftLamArgName.getId() + lamBodySecondArg.getId() should not equal rightLamArgName.getId() } "work for right sections" in { @@ -148,7 +148,7 @@ class SectionsToBinOpTest extends CompilerTest { .asInstanceOf[Name.Literal] lamBodyFirstArg.name shouldEqual lamArgName.name - lamBodyFirstArg.getId should not equal lamArgName.getId + lamBodyFirstArg.getId() should not equal lamArgName.getId() } "work when the section is nested" in {