Skip to content

Commit 7b33caf

Browse files
committed
Add commented out availability.
Add it for public APIs, though we will likely have to add it for internal stuff too as a compiler workaround.
1 parent 4f0eafd commit 7b33caf

13 files changed

+32
-10
lines changed

Sources/System/FilePath/FilePathComponentView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// MARK: - API
1111

12+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1213
extension FilePath {
1314
/// A bidirectional, range replaceable collection of the non-root components
1415
/// that make up a file path.
@@ -97,6 +98,7 @@ extension FilePath.ComponentView: BidirectionalCollection {
9798
}
9899
}
99100

101+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
100102
extension FilePath.ComponentView: RangeReplaceableCollection {
101103
public init() {
102104
self.init(FilePath())

Sources/System/FilePath/FilePathComponents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ extension FilePath {
7373
}
7474
}
7575

76+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
7677
extension FilePath.Component {
7778

7879
/// Whether a component is a regular file or directory name, or a special
@@ -253,7 +254,6 @@ extension FilePath.Root {
253254

254255
// MARK: - Invariants
255256

256-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
257257
extension FilePath.Component {
258258
// TODO: ensure this all gets easily optimized away in release...
259259
internal func _invariantCheck() {

Sources/System/FilePath/FilePathParsing.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ extension SystemString {
111111
}
112112
}
113113

114-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
115114
extension FilePath {
116115
internal mutating func _removeTrailingSeparator() {
117116
_storage._removeTrailingSeparator()

Sources/System/FilePath/FilePathString.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// MARK: - Platform string
1111

12-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
12+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1313
extension FilePath {
1414
/// Creates a file path by copying bytes from a null-terminated platform
1515
/// string.
@@ -39,6 +39,7 @@ extension FilePath {
3939
}
4040
}
4141

42+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4243
extension FilePath.Component {
4344
/// Creates a file path component by copying bytes from a null-terminated
4445
/// platform string.
@@ -75,6 +76,7 @@ extension FilePath.Component {
7576
}
7677
}
7778

79+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
7880
extension FilePath.Root {
7981
/// Creates a file path root by copying bytes from a null-terminated platform
8082
/// string.
@@ -234,6 +236,7 @@ extension FilePath.Root: CustomStringConvertible, CustomDebugStringConvertible {
234236
// MARK: - Convenience helpers
235237

236238
// Convenience helpers
239+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
237240
extension FilePath {
238241
/// Creates a string by interpreting the path’s content as UTF-8 on Unix
239242
/// and UTF-16 on Windows.
@@ -244,6 +247,7 @@ extension FilePath {
244247
}
245248
}
246249

250+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
247251
extension FilePath.Component {
248252
/// Creates a string by interpreting the component’s content as UTF-8 on Unix
249253
/// and UTF-16 on Windows.
@@ -254,6 +258,7 @@ extension FilePath.Component {
254258
}
255259
}
256260

261+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
257262
extension FilePath.Root {
258263
/// On Unix, this returns `"/"`.
259264
///
@@ -380,6 +385,7 @@ extension String {
380385

381386
// MARK: - Deprecations
382387

388+
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
383389
extension String {
384390
@available(*, deprecated, renamed: "init(decoding:)")
385391
public init(_ path: FilePath) { self.init(decoding: path) }
@@ -388,6 +394,7 @@ extension String {
388394
public init?(validatingUTF8 path: FilePath) { self.init(validating: path) }
389395
}
390396

397+
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
391398
extension FilePath {
392399
@available(*, deprecated, renamed: "init(platformString:)")
393400
public init(cString: UnsafePointer<CChar>) {

Sources/System/FilePath/FilePathSyntax.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// MARK: - Query API
1111

12-
// @available(...)
12+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1313
extension FilePath {
1414
/// Returns true if this path uniquely identifies the location of
1515
/// a file without reference to an additional starting location.
@@ -103,6 +103,7 @@ extension FilePath {
103103
}
104104

105105
// MARK: - Decompose a path
106+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
106107
extension FilePath {
107108
/// Returns the root of a path if there is one, otherwise `nil`.
108109
///
@@ -187,6 +188,7 @@ extension FilePath {
187188
}
188189
}
189190

191+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
190192
extension FilePath {
191193
/// Returns the final component of the path.
192194
/// Returns `nil` if the path is empty or only contains a root.
@@ -258,6 +260,7 @@ extension FilePath {
258260
}
259261
}
260262

263+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
261264
extension FilePath.Component {
262265
/// The extension of this file or directory component.
263266
///
@@ -290,6 +293,7 @@ extension FilePath.Component {
290293
}
291294
}
292295

296+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
293297
extension FilePath {
294298

295299
/// The extension of the file or directory last component.
@@ -356,6 +360,7 @@ extension FilePath {
356360

357361
}
358362

363+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
359364
extension FilePath {
360365
/// Whether the path is in lexical-normal form, that is `.` and `..`
361366
/// components have been collapsed lexically (i.e. without following
@@ -436,6 +441,7 @@ extension FilePath {
436441
}
437442

438443
// Modification and concatenation API
444+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
439445
extension FilePath {
440446
/// If `prefix` is a prefix of `self`, removes it and returns `true`.
441447
/// Otherwise returns `false`.
@@ -605,6 +611,7 @@ extension FilePath {
605611
}
606612

607613
// MARK - Renamed
614+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
608615
extension FilePath {
609616
@available(*, unavailable, renamed: "removingLastComponent()")
610617
public var dirname: FilePath { removingLastComponent() }

Sources/System/Platform/Platform.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public typealias CModeT = CInterop.Mode
1818

1919
/// A namespace for C and platform types
20+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2021
public enum CInterop {
2122
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
2223
/// The C `mode_t` type.

Sources/System/Platform/PlatformString.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1011
extension CInterop {
1112
#if os(Windows)
1213
/// The platform's preferred character type. On Unix, this is an 8-bit C
@@ -54,6 +55,7 @@ extension CInterop.PlatformUnicodeEncoding.CodeUnit {
5455
}
5556
}
5657

58+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5759
extension String {
5860
/// Creates a string by interpreting the null-terminated platform string as
5961
/// UTF-8 on Unix and UTF-16 on Windows.

Tests/SystemTests/FilePathTests/FilePathComponentsTest.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import XCTest
1515
@testable import System
1616
#endif
1717

18-
// @available(9999....)
18+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1919
struct TestPathComponents: TestCase {
2020
var path: FilePath
2121
var expectedRoot: FilePath.Root?
@@ -100,9 +100,7 @@ struct TestPathComponents: TestCase {
100100
}
101101
}
102102

103-
// TODO: Note that double-reversal will drop root if FilePath is constructed in between ...
104-
105-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
103+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
106104
final class FilePathComponentsTest: XCTestCase {
107105
func testAdHocRRC() {
108106
var path: FilePath = "/usr/local/bin"

Tests/SystemTests/FilePathTests/FilePathExtras.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#endif
77

88
// Why can't I write this extension on `FilePath.ComponentView.SubSequence`?
9+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
910
extension Slice where Base == FilePath.ComponentView {
1011
internal var _storageSlice: SystemString.SubSequence {
1112
base._path._storage[self.startIndex._storage ..< self.endIndex._storage]
@@ -14,6 +15,7 @@ extension Slice where Base == FilePath.ComponentView {
1415

1516

1617
// Proposed API that didn't make the cut, but we stil want to keep our testing for
18+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1719
extension FilePath {
1820
/// Returns `self` relative to `base`.
1921
/// This does not cosult the file system or resolve symlinks.

Tests/SystemTests/FilePathTests/FilePathParsingTest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ extension ParsingTestCase {
6868
@testable import System
6969
#endif
7070

71+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
7172
final class FilePathParsingTest: XCTestCase {
7273
func testNormalization() {
7374
let unixPaths: Array<ParsingTestCase> = [

0 commit comments

Comments
 (0)