Skip to content

Commit 342b7cd

Browse files
committed
Drop finalization markers
Seems unnecessary.
1 parent 8c09a87 commit 342b7cd

9 files changed

+8
-127
lines changed

Sources/ManagedModels/Schema/Attribute.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ public extension Schema {
1919
}
2020
private var _isUnique = false
2121

22-
final override public var isFinalized: Bool {
23-
set { _isFinalized = newValue }
24-
get { _isFinalized }
25-
}
26-
private var _isFinalized = false
27-
2822

2923
// MARK: - Initializers
3024

Sources/ManagedModels/Schema/Relationship.swift

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,13 @@ public extension Schema {
1313
*/
1414
final class Relationship: CoreData.NSRelationshipDescription, SchemaProperty {
1515

16-
public var keypath : AnyKeyPath? {
17-
willSet {
18-
guard keypath != newValue else { return }
19-
ensureNotFinalized()
20-
}
21-
}
22-
public var inverseKeyPath : AnyKeyPath? {
23-
willSet {
24-
guard inverseKeyPath != newValue else { return }
25-
ensureNotFinalized()
26-
}
27-
}
28-
29-
public var valueType: Any.Type = Any.self {
30-
willSet {
31-
guard valueType != newValue else { return }
32-
ensureNotFinalized()
33-
}
34-
}
16+
public var keypath : AnyKeyPath?
17+
public var inverseKeyPath : AnyKeyPath?
18+
public var valueType : Any.Type = Any.self
3519

3620
final override public var inverseName: String? {
3721
set {
3822
guard _inverseName != newValue else { return }
39-
ensureNotFinalized()
4023
_inverseName = newValue
4124
}
4225
get { _inverseName }
@@ -46,7 +29,6 @@ public extension Schema {
4629
final override public var destination: String {
4730
set {
4831
guard _destination != newValue else { return }
49-
ensureNotFinalized()
5032
_destination = newValue
5133
}
5234
get { _destination }
@@ -59,25 +41,19 @@ public extension Schema {
5941
}
6042
private var _isUnique = false
6143

62-
override public var isToOneRelationship : Bool {
63-
_isToOneRelationship ?? !(valueType is any RelationshipCollection.Type)
44+
45+
override public var isToMany: Bool {
46+
if let _isToOneRelationship { return !_isToOneRelationship }
47+
return valueType is any RelationshipCollection.Type
48+
|| valueType is NSOrderedSet.Type
6449
}
6550
var _isToOneRelationship : Bool? {
6651
willSet {
6752
guard _isToOneRelationship != newValue else { return }
6853
assert(_isToOneRelationship == nil)
69-
ensureNotFinalized()
7054
}
7155
}
72-
73-
override public var isToMany: Bool { !isToOneRelationship }
7456

75-
final override public var isFinalized: Bool {
76-
set { _isFinalized = newValue }
77-
get { _isFinalized }
78-
}
79-
private var _isFinalized = false
80-
8157

8258
// MARK: - Initializers
8359

Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import CoreData
77

8-
extension CoreData.NSAttributeDescription: FinalizableObject {}
9-
108
@available(iOS 11.0, *) // could backport further
119
extension CoreData.NSAttributeDescription: SchemaProperty {
1210

@@ -51,7 +49,6 @@ extension CoreData.NSAttributeDescription: SchemaProperty {
5149
}
5250
}
5351
set {
54-
ensureNotFinalized()
5552
if newValue == Int.self {
5653
self.attributeType = .integer64AttributeType
5754
self.isOptional = false

Sources/ManagedModels/SchemaCompatibility/NSEntityDescription+Data.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55

66
import CoreData
77

8-
extension CoreData.NSEntityDescription: FinalizableObject {
9-
10-
public func markAsFinalized() {
11-
guard !isFinalized else { return }
12-
isFinalized = true
13-
for attribute in attributes { attribute .isFinalized = true }
14-
for relationship in relationships { relationship.isFinalized = true }
15-
}
16-
}
17-
188
public extension CoreData.NSEntityDescription {
199
// Note: `uniquenessConstraints` is String only in SwiftData
2010

@@ -113,8 +103,6 @@ public extension NSEntityDescription {
113103
extension NSEntityDescription {
114104

115105
func addProperties(_ newProperties: [ NSPropertyDescription ]) {
116-
if newProperties.isEmpty { return }
117-
ensureNotFinalized()
118106
for newProperty in newProperties {
119107
properties.append(newProperty)
120108
}

Sources/ManagedModels/SchemaCompatibility/NSRelationshipDescription+Data.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import CoreData
77

8-
extension CoreData.NSRelationshipDescription: FinalizableObject {}
9-
108
extension CoreData.NSRelationshipDescription {
119

1210
public typealias DeleteRule = NSDeleteRule

Sources/ManagedModels/SchemaGeneration/NSEntityDescription+Generation.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ extension NSEntityDescription {
6464
// different setups/configs.
6565

6666
if let template = template as? NSAttributeDescription {
67-
template.isFinalized = true // make sure no one touches the templates
6867
let attribute = template.copy() as! NSAttributeDescription
6968
fixup(attribute, targetType: targetType, meta: propMeta)
7069
return attribute
7170
}
7271

7372
if let template = template as? NSRelationshipDescription {
74-
template.isFinalized = true // make sure no one touches the templates
7573
let relationship = template.copy() as! NSRelationshipDescription
7674
switch RelationshipTargetType(targetType) {
7775
case .attribute(_):
@@ -114,7 +112,6 @@ extension NSEntityDescription {
114112
defaultValue: propMeta.defaultValue
115113
)
116114
fixup(attribute, targetType: valueType, meta: propMeta)
117-
attribute.markAsFinalized() // Those are never massaged afterwards.
118115
return attribute
119116

120117
case .toOne(modelType: _, optional: _):

Sources/ManagedModels/SchemaGeneration/NSRelationshipDescription+Inverse.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,26 @@ extension Schema.Relationship {
2727
if self.inverseRelationship == nil ||
2828
self.inverseRelationship !== newInverseRelationship
2929
{
30-
self.ensureNotFinalized()
3130
self.inverseRelationship = newInverseRelationship
3231
}
3332
// get only in baseclass: inverseRelationship.inverseName
3433
if inverseName == nil || inverseName != newInverseRelationship.name {
35-
self.ensureNotFinalized()
3634
inverseName = newInverseRelationship.name
3735
}
3836
if destinationEntity == nil ||
3937
destinationEntity != newInverseRelationship.entity
4038
{
41-
self.ensureNotFinalized()
4239
destinationEntity = newInverseRelationship.entity
4340
}
4441
if newInverseRelationship.destinationEntity == nil ||
4542
newInverseRelationship.destinationEntity != entity
4643
{
47-
newInverseRelationship.ensureNotFinalized()
4844
newInverseRelationship.destinationEntity = entity
4945
}
5046

5147
if newInverseRelationship.inverseRelationship == nil ||
5248
newInverseRelationship.inverseRelationship !== self
5349
{
54-
newInverseRelationship.ensureNotFinalized()
5550
newInverseRelationship.inverseRelationship = self
5651
}
5752
}
@@ -66,25 +61,21 @@ extension Schema.Relationship {
6661
if inverseKeyPath == nil ||
6762
inverseKeyPath != newInverseRelationship.keypath
6863
{
69-
self.ensureNotFinalized()
7064
inverseKeyPath = newInverseRelationship.keypath
7165
}
7266
if inverseName == nil || inverseName != newInverseRelationship.name {
73-
self.ensureNotFinalized()
7467
inverseName = newInverseRelationship.name
7568
}
7669

7770
if newInverseRelationship.inverseKeyPath == nil ||
7871
newInverseRelationship.inverseKeyPath != keypath
7972
{
80-
newInverseRelationship.ensureNotFinalized()
8173
newInverseRelationship.inverseKeyPath = keypath
8274
}
8375
if newInverseRelationship.inverseName == nil ||
8476
newInverseRelationship.inverseName != name
8577
{
8678
// also fill inverse if not set
87-
newInverseRelationship.ensureNotFinalized()
8879
newInverseRelationship.inverseName = name
8980
}
9081

Sources/ManagedModels/SchemaGeneration/SchemaBuilder.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ public final class SchemaBuilder {
156156
// Lookup inverse relationships
157157
fillInverseRelationshipData(entitiesByType.values)
158158

159-
entitiesByType.values.forEach { $0.markAsFinalized() }
160159
frozenTypes.formUnion(entitiesByType.keys)
161160
}
162161

Sources/ManagedModels/Utilities/FinalizableObject.swift

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)