Revert "Avoid copying IR nodes when no change is performed in passes (#10839)"

Partial revert of commit a65383a47b.
Workaround for #10985.
This commit is contained in:
Hubert Plociniczak 2024-09-09 16:48:33 +02:00
parent fa1e14945a
commit bfa6ca47c4
38 changed files with 436 additions and 1039 deletions

View File

@ -98,8 +98,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
_,
Some(onlyNames),
_,
_,
false,
_,
_
) =>
getImportTargets(moduleImport, bindingMap) match {
@ -149,8 +149,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
true,
_,
hiddenNames,
_,
false,
_,
_
) =>
getImportTargets(moduleImport, bindingMap) match {
@ -207,8 +207,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
_,
_,
_,
_,
false,
_,
_
) =>
val symbolPath = importPath.name
@ -230,8 +230,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
_,
_,
_,
_,
false,
_,
_
) =>
tryAddEncounteredSymbol(

View File

@ -93,8 +93,8 @@ case object ImportSymbolAnalysis extends IRPass {
isAll,
_,
_,
_,
isSynthetic,
_,
_
) if isAll && !isSynthetic =>
bindingMap.resolvedImports.find(_.importDef == imp) match {

View File

@ -40,8 +40,8 @@ case object ModuleNameConflicts extends IRPass {
_,
_,
None,
None,
true,
None,
_
) =>
Some(mod)

View File

@ -185,8 +185,8 @@ final class ImportResolver(compiler: Compiler) extends ImportResolverForIR {
expName,
rename,
onlyNames,
_,
isSynthetic,
_,
_
) if !isSynthetic =>
val exportsItself = curModName.equals(expName.name)

View File

@ -155,11 +155,10 @@ class MetadataStorageTest extends CompilerTest {
meta1 shouldEqual meta2
val meta = TestPass1.Metadata1()
meta1.update(TestPass1, meta)
meta2.update(TestPass1, meta)
meta1.update(TestPass1, TestPass1.Metadata1())
meta2.update(TestPass1, TestPass1.Metadata1())
meta1 shouldNot equal(meta2)
meta1 shouldEqual meta2
}
def newMetadataStorage(init: Seq[MetadataPair[_]]): MetadataStorage = {
@ -186,7 +185,7 @@ class MetadataStorageTest extends CompilerTest {
meta.map((p, m) => (p, m.metadataName)).asScala shouldEqual expected
}
"allow copying to create a new instance with the same data but are not equal" in {
"allow copying to create a new instance with the same data" in {
val meta = newMetadataStorage(
Seq(
new MetadataPair(TestPass1, TestPass1.Metadata1()),
@ -201,8 +200,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 {

View File

@ -1804,7 +1804,7 @@ final class TreeToIr {
return new Import.Module(
qualifiedName, rename, isAll || onlyNames.isDefined() || hidingNames.isDefined(),
onlyNames,
hidingNames, getIdentifiedLocation(imp), false,
hidingNames, false, getIdentifiedLocation(imp),
meta()
);
} catch (SyntaxException err) {
@ -1868,7 +1868,7 @@ final class TreeToIr {
}
return new Export.Module(
qualifiedName, rename, onlyNames,
getIdentifiedLocation(exp), false,
false, getIdentifiedLocation(exp),
meta()
);
} catch (SyntaxException err) {

View File

@ -214,7 +214,7 @@ public final class MetadataStorage {
return true;
}
if (obj instanceof MetadataStorage other) {
return this.metadata == other.metadata;
return Objects.equals(this.metadata, other.metadata);
}
return false;
}

View File

@ -68,19 +68,15 @@ object CallArgument {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Specified = {
if (
name != this.name
|| value != this.value
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Specified(name, value, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Specified(
name,
value,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -118,28 +118,17 @@ object DefinitionArgument {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Specified = {
if (
name != this.name
|| ascribedType != this.ascribedType
|| defaultValue != this.defaultValue
|| suspended != this.suspended
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Specified(
name,
ascribedType,
defaultValue,
suspended,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Specified(
name,
ascribedType,
defaultValue,
suspended,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
override def withName(ir: Name): DefinitionArgument = copy(name = ir)

View File

@ -33,17 +33,10 @@ sealed case class Empty(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Empty = {
if (
location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Empty(location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Empty(location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -85,26 +85,16 @@ object Expression {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Block = {
if (
expressions != this.expressions
|| returnValue != this.returnValue
|| suspended != this.suspended
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Block(
expressions,
returnValue,
location,
suspended,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Block(
expressions,
returnValue,
location,
suspended,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -227,19 +217,10 @@ object Expression {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binding = {
if (
name != this.name
|| expression != this.expression
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Binding(name, expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Binding(name, expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -113,27 +113,17 @@ object Function {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Lambda = {
if (
arguments != this.arguments
|| body != this.body
|| location != this.location
|| canBeTCO != this.canBeTCO
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
Lambda(
arguments,
Persistance.Reference.of(body, false),
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Lambda(
arguments,
Persistance.Reference.of(body, false),
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -277,31 +267,19 @@ object Function {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binding = {
if (
name != this.name
|| arguments != this.arguments
|| body != this.body
|| isPrivate != this.isPrivate
|| location != this.location
|| canBeTCO != this.canBeTCO
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
Binding(
name,
arguments,
body,
isPrivate,
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Binding(
name,
arguments,
body,
isPrivate,
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -61,19 +61,10 @@ object Literal {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Number = {
if (
base != this.base
|| value != this.value
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Number(base, value, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Number(base, value, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -194,18 +185,10 @@ object Literal {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Text = {
if (
text != this.text
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Text(text, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Text(text, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -74,29 +74,18 @@ final case class Module(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Module = {
if (
imports != this.imports
|| exports != this.exports
|| bindings != this.bindings
|| isPrivate != this.isPrivate
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
Module(
imports,
exports,
bindings,
isPrivate,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Module(
imports,
exports,
bindings,
isPrivate,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -72,25 +72,16 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): MethodReference = {
if (
typePointer != this.typePointer
|| methodName != this.methodName
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
MethodReference(
typePointer,
methodName,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
MethodReference(
typePointer,
methodName,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -243,18 +234,11 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Qualified = {
if (
parts != this.parts
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Qualified(parts, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Qualified(parts, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -315,17 +299,10 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Blank = {
if (
location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Blank(location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Blank(location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -396,18 +373,10 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Special = {
if (
specialName != this.specialName
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Special(specialName, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Special(specialName, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
override def duplicate(
@ -500,20 +469,11 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Literal = {
if (
name != this.name
|| isMethod != this.isMethod
|| location != this.location
|| originalName != this.originalName
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Literal(name, isMethod, location, originalName, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Literal(name, isMethod, location, originalName, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -611,18 +571,10 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): BuiltinAnnotation = {
if (
name != this.name
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = BuiltinAnnotation(name, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = BuiltinAnnotation(name, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -705,20 +657,11 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): GenericAnnotation = {
if (
name != this.name
|| expression != this.expression
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
GenericAnnotation(name, expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
GenericAnnotation(name, expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -817,18 +760,10 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Self = {
if (
synthetic != this.synthetic
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Self(location, synthetic, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Self(location, synthetic, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -917,17 +852,10 @@ object Name {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): SelfType = {
if (
location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = SelfType(location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = SelfType(location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -63,18 +63,10 @@ object Pattern {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Name = {
if (
name != this.name
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Name(name, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Name(name, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -165,19 +157,11 @@ object Pattern {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Constructor = {
if (
constructor != this.constructor
|| fields != this.fields
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Constructor(constructor, fields, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Constructor(constructor, fields, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -321,18 +305,10 @@ object Pattern {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Literal = {
if (
literal != this.literal
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Literal(literal, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Literal(literal, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -425,19 +401,10 @@ object Pattern {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Type = {
if (
name != this.name
|| tpe != this.tpe
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Type(name, tpe, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Type(name, tpe, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -546,18 +513,10 @@ object Pattern {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Documentation = {
if (
doc != this.doc
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Documentation(doc, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Documentation(doc, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -50,19 +50,10 @@ object Type {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Function = {
if (
args != this.args
|| result != this.result
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Function(args, result, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Function(args, result, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -166,20 +157,11 @@ object Type {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Ascription = {
if (
typed != this.typed
|| signature != this.signature
|| comment != this.comment
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Ascription(typed, signature, comment, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Ascription(typed, signature, comment, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -282,19 +264,10 @@ object Type {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Context = {
if (
typed != this.typed
|| context != this.context
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Context(typed, context, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Context(typed, context, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -394,19 +367,10 @@ object Type {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Error = {
if (
typed != this.typed
|| error != this.error
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Error(typed, error, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Error(typed, error, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -81,27 +81,17 @@ object Application {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Prefix = {
if (
function != this.function
|| arguments != this.arguments
|| hasDefaultsSuspended != this.hasDefaultsSuspended
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
Prefix(
function,
arguments,
hasDefaultsSuspended,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Prefix(
function,
arguments,
hasDefaultsSuspended,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -200,18 +190,10 @@ object Application {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Force = {
if (
target != this.target
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Force(target, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Force(target, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -324,18 +306,10 @@ object Application {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Typeset = {
if (
expression != this.expression
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Typeset(expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Typeset(expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -427,18 +401,10 @@ object Application {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Sequence = {
if (
items != this.items
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Sequence(items, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Sequence(items, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -68,20 +68,11 @@ object Case {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Expr = {
if (
scrutinee != this.scrutinee
|| branches != this.branches
|| isNested != this.isNested
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Expr(scrutinee, branches, isNested, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Expr(scrutinee, branches, isNested, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -195,26 +186,16 @@ object Case {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Branch = {
if (
pattern != this.pattern
|| expression != this.expression
|| terminalBranch != this.terminalBranch
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Branch(
pattern,
expression,
terminalBranch,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Branch(
pattern,
expression,
terminalBranch,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -59,18 +59,10 @@ object Comment {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Documentation = {
if (
doc != this.doc
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Documentation(doc, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Documentation(doc, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -57,17 +57,10 @@ object Error {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): InvalidIR = {
if (
ir != this.ir
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = InvalidIR(ir, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = InvalidIR(ir, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -66,19 +66,10 @@ object Foreign {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Definition = {
if (
lang != this.lang
|| code != this.code
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Definition(lang, code, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Definition(lang, code, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -67,20 +67,11 @@ object Operator {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binary = {
if (
left != this.left
|| operator != this.operator
|| right != this.right
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Binary(left, operator, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Binary(left, operator, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -63,19 +63,10 @@ object Section {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Left = {
if (
arg != this.arg
|| operator != this.operator
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Left(arg, operator, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Left(arg, operator, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -171,18 +162,10 @@ object Section {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Sides = {
if (
operator != this.operator
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Sides(operator, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Sides(operator, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -273,19 +256,10 @@ object Section {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Right = {
if (
operator != this.operator
|| arg != this.arg
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Right(operator, arg, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Right(operator, arg, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -52,18 +52,10 @@ sealed case class Conversion(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Conversion = {
if (
storedIr != this.storedIr
|| reason != this.reason
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Conversion(storedIr, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Conversion(storedIr, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -59,18 +59,10 @@ sealed case class ImportExport(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): ImportExport = {
if (
ir != this.ir
|| reason != this.reason
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = ImportExport(ir, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = ImportExport(ir, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -64,18 +64,10 @@ sealed case class Pattern(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Pattern = {
if (
originalPattern != this.originalPattern
|| reason != this.reason
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Pattern(originalPattern, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Pattern(originalPattern, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -60,17 +60,10 @@ object Redefined {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): SelfArg = {
if (
location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = SelfArg(location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = SelfArg(location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -155,19 +148,11 @@ object Redefined {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Conversion = {
if (
targetType != this.targetType
|| sourceType != this.sourceType
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Conversion(targetType, sourceType, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Conversion(targetType, sourceType, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -268,7 +253,7 @@ object Redefined {
/** Creates a copy of `this`.
*
* @param typeName the name of the atom the method was being redefined on
* @param atomName the name of the atom the method was being redefined on
* @param methodName the method name being redefined on `atomName`
* @param location the location in the source to which this error
* corresponds
@ -278,26 +263,18 @@ object Redefined {
* @return a copy of `this`, updated with the specified values
*/
def copy(
typeName: Option[Name] = typeName,
atomName: Option[Name] = typeName,
methodName: Name = methodName,
location: Option[IdentifiedLocation] = location,
passData: MetadataStorage = passData,
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Method = {
if (
typeName != this.typeName
|| methodName != this.methodName
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Method(typeName, methodName, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Method(atomName, methodName, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -308,7 +285,7 @@ object Redefined {
keepIdentifiers: Boolean = false
): Method =
copy(
typeName = typeName.map(
atomName = typeName.map(
_.duplicate(
keepLocations,
keepMetadata,
@ -415,24 +392,15 @@ object Redefined {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): MethodClashWithAtom = {
if (
atomName != this.atomName
|| methodName != this.methodName
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = MethodClashWithAtom(
atomName,
methodName,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = MethodClashWithAtom(
atomName,
methodName,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -533,24 +501,17 @@ object Redefined {
* @return a copy of `this`, updated with the specified values
*/
def copy(
typeName: Name = typeName,
atomName: Name = typeName,
location: Option[IdentifiedLocation] = location,
passData: MetadataStorage = passData,
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Type = {
if (
typeName != this.typeName
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Type(typeName, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Type(atomName, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -561,7 +522,7 @@ object Redefined {
keepIdentifiers: Boolean = false
): Type =
copy(
typeName = typeName.duplicate(
atomName = typeName.duplicate(
keepLocations,
keepMetadata,
keepDiagnostics,
@ -646,18 +607,11 @@ object Redefined {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID = id
): Arg = {
if (
name != this.name
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Arg(name, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Arg(name, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -748,17 +702,10 @@ object Redefined {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binding = {
if (
invalidBinding != this.invalidBinding
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Binding(invalidBinding, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Binding(invalidBinding, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -68,18 +68,10 @@ sealed case class Resolution(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Resolution = {
if (
originalName != this.originalName
|| reason != this.reason
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Resolution(originalName, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Resolution(originalName, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -60,18 +60,10 @@ sealed case class Syntax(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Syntax = {
if (
at != this.at
|| reason != this.reason
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Syntax(at, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Syntax(at, reason, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -73,17 +73,10 @@ object Unexpected {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): TypeSignature = {
if (
ir != this.ir
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = TypeSignature(ir, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = TypeSignature(ir, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -73,20 +73,11 @@ object Definition {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Type = {
if (
name != this.name
|| params != this.params
|| members != this.members
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Type(name, params, members, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Type(name, params, members, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -200,28 +191,17 @@ object Definition {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Data = {
if (
name != this.name
|| arguments != this.arguments
|| annotations != this.annotations
|| isPrivate != this.isPrivate
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Data(
name,
arguments,
annotations,
isPrivate,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Data(
name,
arguments,
annotations,
isPrivate,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -333,26 +313,16 @@ object Definition {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): SugaredType = {
if (
name != this.name
|| arguments != this.arguments
|| body != this.body
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = SugaredType(
name,
arguments,
body,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = SugaredType(
name,
arguments,
body,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -51,9 +51,9 @@ object Export {
name: Name.Qualified,
rename: Option[Name.Literal],
onlyNames: Option[List[Name.Literal]],
override val location: Option[IdentifiedLocation],
isSynthetic: Boolean = false,
override val passData: MetadataStorage = new MetadataStorage()
isSynthetic: Boolean = false,
override val location: Option[IdentifiedLocation] = None,
override val passData: MetadataStorage = new MetadataStorage()
) extends IR
with IRKind.Primitive
with Export
@ -82,28 +82,17 @@ object Export {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Module = {
if (
name != this.name
|| rename != this.rename
|| onlyNames != this.onlyNames
|| isSynthetic != this.isSynthetic
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Module(
name,
rename,
onlyNames,
location,
isSynthetic,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Module(
name,
rename,
onlyNames,
isSynthetic,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -55,9 +55,9 @@ object Import {
isAll: Boolean,
onlyNames: Option[List[Name.Literal]],
hiddenNames: Option[List[Name.Literal]],
override val location: Option[IdentifiedLocation],
isSynthetic: Boolean = false,
override val passData: MetadataStorage = new MetadataStorage()
isSynthetic: Boolean = false,
override val location: Option[IdentifiedLocation] = None,
override val passData: MetadataStorage = new MetadataStorage()
) extends Import
with IRKind.Primitive
with LazyDiagnosticStorage
@ -89,32 +89,19 @@ object Import {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Module = {
if (
name != this.name
|| rename != this.rename
|| isAll != this.isAll
|| onlyNames != this.onlyNames
|| hiddenNames != this.hiddenNames
|| isSynthetic != this.isSynthetic
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Module(
name,
rename,
isAll,
onlyNames,
hiddenNames,
location,
isSynthetic,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Module(
name,
rename,
isAll,
onlyNames,
hiddenNames,
isSynthetic,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -54,10 +54,10 @@ object Method {
methodReference: Name.MethodReference,
bodyReference: Persistance.Reference[Expression],
isStatic: Boolean,
override val isPrivate: Boolean,
isPrivate: Boolean,
isStaticWrapperForInstanceMethod: Boolean,
override val location: Option[IdentifiedLocation],
override val passData: MetadataStorage
location: Option[IdentifiedLocation],
passData: MetadataStorage
) extends Method
with IRKind.Primitive
with LazyDiagnosticStorage
@ -108,30 +108,18 @@ object Method {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Explicit = {
if (
methodReference != this.methodReference
|| body != this.body
|| isStatic != this.isStatic
|| isPrivate != this.isPrivate
|| isStaticWrapperForInstanceMethod != this.isStaticWrapperForInstanceMethod
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Explicit(
methodReference,
Persistance.Reference.of(body, false),
isStatic,
isPrivate,
isStaticWrapperForInstanceMethod,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Explicit(
methodReference,
Persistance.Reference.of(body, false),
isStatic,
isPrivate,
isStaticWrapperForInstanceMethod,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -316,28 +304,17 @@ object Method {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binding = {
if (
methodReference != this.methodReference
|| arguments != this.arguments
|| isPrivate != this.isPrivate
|| body != this.body
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Binding(
methodReference,
arguments,
isPrivate,
body,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Binding(
methodReference,
arguments,
isPrivate,
body,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -485,26 +462,16 @@ object Method {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Conversion = {
if (
methodReference != this.methodReference
|| sourceTypeName != this.sourceTypeName
|| body != this.body
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Conversion(
methodReference,
sourceTypeName,
body,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Conversion(
methodReference,
sourceTypeName,
body,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -51,19 +51,11 @@ sealed case class Polyglot(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Polyglot = {
if (
entity != this.entity
|| rename != this.rename
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Polyglot(entity, rename, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Polyglot(entity, rename, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -69,20 +69,11 @@ object Set {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Member = {
if (
label != this.label
|| memberType != this.memberType
|| value != this.value
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Member(label, memberType, value, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Member(label, memberType, value, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -198,19 +189,10 @@ object Set {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Subsumption = {
if (
left != this.left
|| right != this.right
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Subsumption(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Subsumption(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -311,19 +293,10 @@ object Set {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Equality = {
if (
left != this.left
|| right != this.right
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Equality(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Equality(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -424,19 +397,10 @@ object Set {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Concat = {
if (
left != this.left
|| right != this.right
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Concat(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Concat(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -532,18 +496,10 @@ object Set {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Union = {
if (
operands != this.operands
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Union(operands, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Union(operands, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */
@ -638,19 +594,10 @@ object Set {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Intersection = {
if (
left != this.left
|| right != this.right
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Intersection(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Intersection(left, right, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}
/** @inheritdoc */

View File

@ -16,7 +16,6 @@ import org.enso.compiler.core.ir.Module;
import org.enso.persist.Persistable;
import org.enso.persist.Persistance;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openide.util.lookup.ServiceProvider;
import scala.Option;
@ -283,7 +282,6 @@ public class IrPersistanceTest {
assertNotSame("deserialized s1", in.last(), out.last());
}
@Ignore
@Test
public void serializeModule() throws Exception {
var meta = new MetadataStorage();