Skip to content

[6.2][PackageModel] Toolchain: A few fixes for features supported by Swift compiler #8762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Sources/PackageModel/Toolchain+SupportedFeatures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ extension Toolchain {

let features: JSON = try parsedSupportedFeatures.get("features")

let optional: [SwiftCompilerFeature] = try (features.get("optional") as [JSON]?)?.map { (json: JSON) in
let optionalFeatures = (try? features.getArray("optional")) ?? []

let optional: [SwiftCompilerFeature] = try optionalFeatures.map { json in
let name: String = try json.get("name")
let categories: [String]? = try json.getArrayIfAvailable("categories")
let migratable: Bool? = json.get("migratable")
Expand All @@ -114,13 +116,17 @@ extension Toolchain {
categories: categories ?? [name],
flagName: flagName
)
} ?? []
}

let upcoming: [SwiftCompilerFeature] = try features.getArray("upcoming").map {
let name: String = try $0.get("name")
let categories: [String]? = try $0.getArrayIfAvailable("categories")
let migratable: Bool? = $0.get("migratable")
let enabledIn: String = try $0.get("enabled_in")
let enabledIn = if let version = try? $0.get(String.self, forKey: "enabled_in") {
version
} else {
try String($0.get(Int.self, forKey: "enabled_in"))
}

guard let mode = SwiftLanguageVersion(string: enabledIn) else {
throw InternalError("Unknown swift language mode: \(enabledIn)")
Expand Down