|
1 | 1 | /*
|
2 | 2 | This source file is part of the Swift.org open source project
|
3 | 3 |
|
4 |
| - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors |
| 4 | + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors |
5 | 5 | Licensed under Apache License v2.0 with Runtime Library Exception
|
6 | 6 |
|
7 | 7 | See https://swift.org/LICENSE.txt for license information
|
@@ -131,30 +131,28 @@ public struct DefaultAvailability: Codable, Equatable {
|
131 | 131 |
|
132 | 132 | /// Fallback availability information for platforms we either don't emit SGFs for
|
133 | 133 | /// or have the same availability information as another platform.
|
134 |
| - /// |
135 |
| - /// The key corresponds to the fallback platform and the value to the platform it's |
136 |
| - /// fallbacking from. |
137 |
| - package static let fallbackPlatforms: [PlatformName: [PlatformName]] = [.iOS: [.catalyst, .iPadOS]] |
| 134 | + package static let fallbackPlatforms: [PlatformName: PlatformName] = [ |
| 135 | + .catalyst: .iOS, |
| 136 | + .iPadOS: .iOS, |
| 137 | + ] |
138 | 138 |
|
139 | 139 | /// Creates a default availability module.
|
140 | 140 | /// - Parameter modules: A map of modules and the default platform availability for symbols in that module.
|
141 | 141 | public init(with modules: [String: [ModuleAvailability]]) {
|
142 | 142 | self.modules = modules.mapValues { platformAvailabilities -> [DefaultAvailability.ModuleAvailability] in
|
143 | 143 | // If a module doesn't contain default availability information for any of the fallback platforms,
|
144 | 144 | // infer it from the corresponding mapped value.
|
145 |
| - platformAvailabilities + DefaultAvailability.fallbackPlatforms.flatMap { (fallbackPlatform, platform) in |
146 |
| - platform.compactMap { platformName in |
147 |
| - if !platformAvailabilities.contains(where: { $0.platformName == platformName }), |
148 |
| - let fallbackAvailability = platformAvailabilities.first(where: { $0.platformName == fallbackPlatform }), |
149 |
| - let fallbackIntroducedVersion = fallbackAvailability.introducedVersion |
150 |
| - { |
151 |
| - return DefaultAvailability.ModuleAvailability( |
152 |
| - platformName: platformName, |
153 |
| - platformVersion: fallbackIntroducedVersion |
154 |
| - ) |
155 |
| - } |
156 |
| - return nil |
| 145 | + platformAvailabilities + DefaultAvailability.fallbackPlatforms.compactMap { (platform, fallbackPlatform) in |
| 146 | + if !platformAvailabilities.contains(where: { $0.platformName == platform }), |
| 147 | + let fallbackAvailability = platformAvailabilities.first(where: { $0.platformName == fallbackPlatform }), |
| 148 | + let fallbackIntroducedVersion = fallbackAvailability.introducedVersion |
| 149 | + { |
| 150 | + return DefaultAvailability.ModuleAvailability( |
| 151 | + platformName: platform, |
| 152 | + platformVersion: fallbackIntroducedVersion |
| 153 | + ) |
157 | 154 | }
|
| 155 | + return nil |
158 | 156 | }
|
159 | 157 | }
|
160 | 158 | }
|
|
0 commit comments