Skip to content

Commit cf85142

Browse files
committed
Move PackageConditionWrapper declaration closer to PackageConditionProtocol declaration
1 parent c6d49ef commit cf85142

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

Sources/PackageModel/Manifest.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,33 @@ public protocol PackageConditionProtocol: Codable {
848848
func satisfies(_ environment: BuildEnvironment) -> Bool
849849
}
850850

851+
/// Wrapper for package condition so it can be conformed to Codable.
852+
struct PackageConditionWrapper: Codable {
853+
var platform: PlatformsCondition?
854+
var config: ConfigurationCondition?
855+
856+
var condition: PackageConditionProtocol {
857+
if let platform = platform {
858+
return platform
859+
} else if let config = config {
860+
return config
861+
} else {
862+
fatalError("unreachable")
863+
}
864+
}
865+
866+
init(_ condition: PackageConditionProtocol) {
867+
switch condition {
868+
case let platform as PlatformsCondition:
869+
self.platform = platform
870+
case let config as ConfigurationCondition:
871+
self.config = config
872+
default:
873+
fatalError("unknown condition \(condition)")
874+
}
875+
}
876+
}
877+
851878
/// Platforms condition implies that an assignment is valid on these platforms.
852879
public struct PlatformsCondition: PackageConditionProtocol {
853880
public let platforms: [Platform]

Sources/PackageModel/PackageModel+Codable.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -156,33 +156,6 @@ extension TargetDescription.Dependency: Codable {
156156
}
157157
}
158158

159-
/// Wrapper for package condition so it can be conformed to Codable.
160-
struct PackageConditionWrapper: Codable {
161-
var platform: PlatformsCondition?
162-
var config: ConfigurationCondition?
163-
164-
var condition: PackageConditionProtocol {
165-
if let platform = platform {
166-
return platform
167-
} else if let config = config {
168-
return config
169-
} else {
170-
fatalError("unreachable")
171-
}
172-
}
173-
174-
init(_ condition: PackageConditionProtocol) {
175-
switch condition {
176-
case let platform as PlatformsCondition:
177-
self.platform = platform
178-
case let config as ConfigurationCondition:
179-
self.config = config
180-
default:
181-
fatalError("unknown condition \(condition)")
182-
}
183-
}
184-
}
185-
186159
extension BinaryTarget.ArtifactSource: Codable {
187160
private enum CodingKeys: String, CodingKey {
188161
case remote, local

0 commit comments

Comments
 (0)