@@ -310,27 +310,28 @@ extension Triple {
310310 ///
311311 /// - SeeAlso: `Triple.supports(_:)`
312312 public struct FeatureAvailability {
313- public let macOS : Triple . Version ?
314- public let iOS : Triple . Version ?
315- public let tvOS : Triple . Version ?
316- public let watchOS : Triple . Version ?
313+
314+ public enum Availability {
315+ case unavailable
316+ case available( since: Version )
317+ case availableInAllVersions
318+ }
319+
320+ public let macOS : Availability
321+ public let iOS : Availability
322+ public let tvOS : Availability
323+ public let watchOS : Availability
317324
318325 // TODO: We should have linux, windows, etc.
319326 public let nonDarwin : Bool
320327
321328 /// Describes the availability of a feature that is supported on multiple platforms,
322329 /// but is tied to a particular version.
323- ///
324- /// Each version parameter is `Optional`; a `nil` value means the feature is
325- /// not supported on any version of that platform. Use `Triple.Version.zero`
326- /// for a feature that is available in all versions.
327- ///
328- /// If `tvOS` availability is omitted, it will be set to be the same as `iOS`.
329330 public init (
330- macOS: Triple . Version ? ,
331- iOS: Triple . Version ? ,
332- tvOS: Triple . Version ? ,
333- watchOS: Triple . Version ? ,
331+ macOS: Availability ,
332+ iOS: Availability ,
333+ tvOS: Availability ,
334+ watchOS: Availability ,
334335 nonDarwin: Bool = false
335336 ) {
336337 self . macOS = macOS
@@ -343,24 +344,20 @@ extension Triple {
343344 /// Describes the availability of a feature that is supported on multiple platforms,
344345 /// but is tied to a particular version.
345346 ///
346- /// Each version parameter is `Optional`; a `nil` value means the feature is
347- /// not supported on any version of that platform. Use `Triple.Version.zero`
348- /// for a feature that is available in all versions.
349- ///
350347 /// If `tvOS` availability is omitted, it will be set to be the same as `iOS`.
351348 public init (
352- macOS: Triple . Version ? ,
353- iOS: Triple . Version ? ,
354- watchOS: Triple . Version ? ,
349+ macOS: Availability ,
350+ iOS: Availability ,
351+ watchOS: Availability ,
355352 nonDarwin: Bool = false
356353 ) {
357354 self . init ( macOS: macOS, iOS: iOS, tvOS: iOS, watchOS: watchOS,
358355 nonDarwin: nonDarwin)
359356 }
360357
361358 /// Returns the version when the feature was introduced on the specified Darwin
362- /// platform, or `nil ` if the feature has not been introduced there.
363- public subscript( darwinPlatform: DarwinPlatform ) -> Triple . Version ? {
359+ /// platform, or `.unavailable ` if the feature has not been introduced there.
360+ public subscript( darwinPlatform: DarwinPlatform ) -> Availability {
364361 switch darwinPlatform {
365362 case . macOS:
366363 return macOS
@@ -380,20 +377,24 @@ extension Triple {
380377 guard let darwinPlatform = darwinPlatform else {
381378 return feature. nonDarwin
382379 }
383- guard let introducedVersion = feature [ darwinPlatform] else {
380+
381+ switch feature [ darwinPlatform] {
382+ case . unavailable:
384383 return false
384+ case . available( let introducedVersion) :
385+ return version ( for: darwinPlatform) >= introducedVersion
386+ case . availableInAllVersions:
387+ return true
385388 }
386-
387- return version ( for: darwinPlatform) >= introducedVersion
388389 }
389390}
390391
391392extension Triple . FeatureAvailability {
392393 /// Linking `libarclite` is unnecessary for triples supporting this feature.
393394 static let compatibleObjCRuntime = Self (
394- macOS: Triple . Version ( 10 , 11 , 0 ) ,
395- iOS: Triple . Version ( 9 , 0 , 0 ) ,
396- watchOS: . zero
395+ macOS: . available ( since : Triple . Version ( 10 , 11 , 0 ) ) ,
396+ iOS: . available ( since : Triple . Version ( 9 , 0 , 0 ) ) ,
397+ watchOS: . availableInAllVersions
397398 )
398399 // When updating the versions listed here, please record the most recent
399400 // feature being depended on and when it was introduced:
0 commit comments