Skip to content

Commit 1612a9d

Browse files
committed
Add AnyAttributeFix to workaround compiler crash
1 parent 170875a commit 1612a9d

22 files changed

+194
-223
lines changed

Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ extension BodyAccessor {
218218
inputs: inout _GraphInputs,
219219
fields: DynamicPropertyCache.Fields
220220
) -> (_GraphValue<Body>, _DynamicPropertyBuffer?) {
221-
#if canImport(Darwin)
222221
guard Body.self != Never.self else {
223222
preconditionFailure("\(Body.self) may not have Body == Never")
224223
}
@@ -253,9 +252,6 @@ extension BodyAccessor {
253252
return project(flags: MainThreadFlags.self)
254253
}
255254
}
256-
#else
257-
preconditionFailure("See #39")
258-
#endif
259255
}
260256
}
261257

@@ -273,8 +269,6 @@ private struct MainThreadFlags: RuleThreadFlags {
273269
static var value: OGAttributeTypeFlags { .mainThread }
274270
}
275271

276-
#if canImport(Darwin)
277-
278272
// MARK: - StaticBody
279273

280274
private struct StaticBody<Accessor: BodyAccessor, ThreadFlags: RuleThreadFlags> {
@@ -404,5 +398,3 @@ extension DynamicBody: BodyAccessorRule {
404398
extension DynamicBody: CustomStringConvertible {
405399
var description: String { "\(Accessor.Body.self)" }
406400
}
407-
408-
#endif

Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,29 @@ package import OpenGraphShims
1212
package struct CachedEnvironment {
1313
package var environment: Attribute<EnvironmentValues>
1414
private var items: [Item]
15-
#if canImport(Darwin)
1615
private var constants: [HashableConstant: AnyAttribute]
17-
#endif
1816
// private var animatedFrame: AnimatedFrame?
1917
// private var resolvedFgStyles: [ResolvedFgStyle : Swift<_ShapeStyle_Resolved.ResolvedFg>]
2018

2119
package init(_ environment: Attribute<EnvironmentValues>) {
2220
self.environment = environment
2321
items = []
24-
#if canImport(Darwin)
2522
constants = [:]
26-
#endif
2723
// animatedFrame = nil
2824
// resolvedFgStyles = [:] FIXME: 0x100: ?
2925
}
3026

3127
package mutating func attribute<Value>(keyPath: KeyPath<EnvironmentValues, Value>) -> Attribute<Value> {
32-
#if canImport(Darwin)
3328
if let item = items.first(where: { $0.key == keyPath }) {
3429
return Attribute(identifier: item.value)
3530
} else {
3631
let value = environment[keyPath: keyPath]
3732
items.append(Item(key: keyPath, value: value.identifier))
3833
return value
3934
}
40-
#else
41-
preconditionFailure("See #39")
42-
#endif
4335
}
4436

4537
package mutating func intern<Value>(_ value: Value, id: Int) -> Attribute<Value> {
46-
#if canImport(Darwin)
4738
let constant = HashableConstant(value, id: id)
4839
if let identifier = constants[constant] {
4940
return Attribute(identifier: identifier)
@@ -52,9 +43,6 @@ package struct CachedEnvironment {
5243
constants[constant] = attribute.identifier
5344
return attribute
5445
}
55-
#else
56-
preconditionFailure("See #39")
57-
#endif
5846
}
5947

6048
func animatedPosition(for inputs: _ViewInputs) -> Attribute<ViewOrigin> {
@@ -75,9 +63,7 @@ package struct CachedEnvironment {
7563
extension CachedEnvironment {
7664
private struct Item {
7765
var key: PartialKeyPath<EnvironmentValues>
78-
#if canImport(Darwin) // See #39
7966
var value: AnyAttribute
80-
#endif
8167
}
8268
}
8369

Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,14 @@ package final class PreferenceBridge {
4545
}
4646

4747
package func wrapInputs(_ inputs: inout _ViewInputs) {
48-
#if canImport(Darwin)
4948
inputs.customInputs = bridgedViewInputs
5049
for key in requestedPreferences {
5150
inputs.preferences.keys.add(key)
5251
}
5352
inputs.preferences.hostKeys = Attribute(MergePreferenceKeys(lhs: inputs.preferences.hostKeys, rhs: _hostPreferenceKeys))
54-
#endif
5553
}
5654

5755
package func wrapOutputs(_ outputs: inout PreferencesOutputs, inputs: _ViewInputs) {
58-
#if canImport(Darwin)
5956
bridgedViewInputs = inputs.customInputs
6057
for key in inputs.preferences.keys {
6158
if key == _AnyPreferenceKey<HostPreferencesKey>.self {
@@ -90,8 +87,6 @@ package final class PreferenceBridge {
9087
outputs[anyKey: key] = result
9188
}
9289
}
93-
#endif
94-
9590
}
9691

9792
package func addChild(_ child: ViewGraph) {
@@ -116,7 +111,6 @@ package final class PreferenceBridge {
116111
}
117112
}
118113

119-
#if canImport(Darwin)
120114
package func addValue(_ src: AnyAttribute, for key: any AnyPreferenceKey.Type) {
121115
struct AddValue: PreferenceKeyVisitor {
122116
var combiner: AnyAttribute
@@ -167,17 +161,13 @@ package final class PreferenceBridge {
167161
viewGraph.graphInvalidation(from: isInvalidating ? nil : src)
168162
}
169163
}
170-
#endif
171-
164+
172165
package func updateHostValues(_ keys: Attribute<PreferenceKeys>) {
173-
#if canImport(Darwin)
174166
guard let viewGraph else { return }
175167
viewGraph.graphInvalidation(from: keys.identifier)
176-
#endif
177168
}
178169

179170
package func addHostValues(_ values: WeakAttribute<PreferenceList>, for keys: Attribute<PreferenceKeys>) {
180-
#if canImport(Darwin)
181171
guard let viewGraph,
182172
let combiner = $hostPreferencesCombiner
183173
else { return }
@@ -188,20 +178,16 @@ package final class PreferenceBridge {
188178
combiner.addChild(keys: keys, values: values)
189179
}
190180
viewGraph.graphInvalidation(from: keys.identifier)
191-
#endif
192181
}
193182

194183
package func addHostValues(_ values: OptionalAttribute<PreferenceList>, for keys: Attribute<PreferenceKeys>) {
195-
#if canImport(Darwin)
196184
guard let attribute = values.attribute else {
197185
return
198186
}
199187
addHostValues(WeakAttribute(attribute), for: keys)
200-
#endif
201188
}
202189

203190
package func removeHostValues(for keys: Attribute<PreferenceKeys>, isInvalidating: Bool = false) {
204-
#if canImport(Darwin)
205191
guard let viewGraph,
206192
let combiner = $hostPreferencesCombiner
207193
else { return }
@@ -220,7 +206,6 @@ package final class PreferenceBridge {
220206
if hasRemoved {
221207
viewGraph.graphInvalidation(from: isInvalidating ? nil : keys.identifier)
222208
}
223-
#endif
224209
}
225210
}
226211

Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package struct PreferencesOutputs {
1717
debugProperties = []
1818
}
1919

20-
#if canImport(Darwin)
2120
subscript(anyKey key: AnyPreferenceKey.Type) -> AnyAttribute? {
2221
get { preferences.first { $0.key == key }?.value }
2322
set {
@@ -39,60 +38,40 @@ package struct PreferencesOutputs {
3938
}
4039
}
4140
}
42-
#endif
43-
41+
4442
subscript<K>(key: K.Type) -> Attribute<K.Value>? where K: PreferenceKey {
4543
get {
46-
#if canImport(Darwin)
4744
let value = self[anyKey: _AnyPreferenceKey<K>.self]
4845
return value.map { Attribute(identifier: $0) }
49-
#else
50-
preconditionFailure("See #39")
51-
#endif
5246
}
5347
set {
54-
#if canImport(Darwin)
5548
self[anyKey: _AnyPreferenceKey<K>.self] = newValue.map { $0.identifier }
56-
#else
57-
preconditionFailure("See #39")
58-
#endif
5949
}
6050
}
6151

6252
package mutating func appendPreference<K>(key: K.Type, value: Attribute<K.Value>) where K: PreferenceKey{
63-
#if canImport(Darwin)
6453
preferences.append(KeyValue(key: _AnyPreferenceKey<K>.self, value: value.identifier))
65-
#else
66-
preconditionFailure("See #39")
67-
#endif
6854
}
69-
70-
#if canImport(Darwin)
55+
7156
package func forEachPreference(_ body: (any AnyPreferenceKey.Type, AnyAttribute) -> Void) {
7257
preferences.forEach { body($0.key, $0.value) }
7358
}
74-
#endif
75-
76-
#if canImport(Darwin)
59+
7760
package func setIndirectDependency(_ dependency: AnyAttribute?) {
7861
preferences.forEach {
7962
$0.value.indirectDependency = dependency
8063
}
8164
}
82-
#endif
83-
65+
8466
package func attachIndirectOutputs(to childOutputs: PreferencesOutputs) {
85-
#if canImport(Darwin)
8667
for preference in preferences {
8768
for childPreference in childOutputs.preferences where childPreference.key == preference.key {
8869
preference.value.source = childPreference.value
8970
}
9071
}
91-
#endif
9272
}
9373

9474
package func detachIndirectOutputs() {
95-
#if canImport(Darwin)
9675
struct ResetPreference: PreferenceKeyVisitor {
9776
var destination: AnyAttribute
9877
func visit<K>(key: K.Type) where K: PreferenceKey {
@@ -103,15 +82,12 @@ package struct PreferencesOutputs {
10382
var visitor = ResetPreference(destination: keyValue.value)
10483
keyValue.key.visitKey(&visitor)
10584
}
106-
#endif
10785
}
10886
}
10987

11088
extension PreferencesOutputs {
11189
private struct KeyValue {
11290
var key: any AnyPreferenceKey.Type
113-
#if canImport(Darwin)
11491
var value: AnyAttribute
115-
#endif
11692
}
11793
}

Sources/OpenSwiftUICore/Data/Preference/View_Indirect.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,33 @@ extension _ViewInputs {
2424
@IndirectAttribute(source: defaultLayoutComputer)
2525
var indirect: LayoutComputer
2626
outputs.layoutComputer = $indirect
27+
#else
28+
preconditionFailure("#39")
2729
#endif
2830
return outputs
2931
}
3032
}
3133

3234
extension _ViewOutputs {
33-
#if canImport(Darwin)
3435
package func setIndirectDependency(_ dependency: AnyAttribute?) {
3536
preferences.setIndirectDependency(dependency)
3637
if let target = layoutComputer?.identifier {
3738
target.indirectDependency = dependency
3839
}
3940
}
40-
#endif
41-
4241

4342
package func attachIndirectOutputs(to childOutputs: _ViewOutputs) {
44-
#if canImport(Darwin)
4543
preferences.attachIndirectOutputs(to: childOutputs.preferences)
4644
if let target = layoutComputer?.identifier,
4745
let source = childOutputs.layoutComputer?.identifier {
4846
target.source = source
4947
}
50-
#endif
5148
}
5249

5350
package func detachIndirectOutputs() {
54-
#if canImport(Darwin)
5551
preferences.detachIndirectOutputs()
5652
if let target = layoutComputer?.identifier {
5753
target.source = .nil
5854
}
59-
#endif
6055
}
6156
}

Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,12 @@ package struct TransactionID: Comparable, Hashable {
262262

263263
@inlinable
264264
package init(context: AnyRuleContext) {
265-
#if canImport(Darwin)
266265
self.init(graph: context.attribute.graph)
267-
#else
268-
preconditionFailure("See #39")
269-
#endif
270266
}
271267

272268
@inlinable
273269
package init<Value>(context: RuleContext<Value>) {
274-
#if canImport(Darwin)
275270
self.init(graph: context.attribute.graph)
276-
#else
277-
preconditionFailure("See #39")
278-
#endif
279271
}
280272

281273
@inlinable

Sources/OpenSwiftUICore/Data/Update.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,12 @@ package enum Update {
123123
if Thread.isMainThread {
124124
body()
125125
} else {
126-
#if canImport(Darwin)
127126
withoutActuallyEscaping(body) { escapableBody in
128127
let context = AnyRuleContext(attribute: AnyOptionalAttribute.current.identifier)
129128
MovableLock.syncMain(lock: _lock) {
130129
context.update(body: escapableBody)
131130
}
132131
}
133-
#else
134-
preconditionFailure("See #39")
135-
#endif
136132
}
137133
#endif
138134
}

0 commit comments

Comments
 (0)