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.
This commit is contained in:
Michael Ilseman committed 2021-02-25 21:11:15 -07:00
1 parent 4f0eafd24e
commit 7b33caf850
13 files changed
+32 -10

No files matched your search

@@ -9,6 +9,7 @@
// MARK: - API
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// A bidirectional, range replaceable collection of the non-root components
/// that make up a file path.
@@ -97,6 +98,7 @@ extension FilePath.ComponentView: BidirectionalCollection {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.ComponentView: RangeReplaceableCollection {
public init() {
self.init(FilePath())
@@ -73,6 +73,7 @@ extension FilePath {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Component {
/// Whether a component is a regular file or directory name, or a special
@@ -253,7 +254,6 @@ extension FilePath.Root {
// MARK: - Invariants
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Component {
// TODO: ensure this all gets easily optimized away in release...
internal func _invariantCheck() {
@@ -111,7 +111,6 @@ extension SystemString {
}
}
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
extension FilePath {
internal mutating func _removeTrailingSeparator() {
_storage._removeTrailingSeparator()
+8 -1
View File
@@ -9,7 +9,7 @@
// MARK: - Platform string
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Creates a file path by copying bytes from a null-terminated platform
/// string.
@@ -39,6 +39,7 @@ extension FilePath {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Component {
/// Creates a file path component by copying bytes from a null-terminated
/// platform string.
@@ -75,6 +76,7 @@ extension FilePath.Component {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Root {
/// Creates a file path root by copying bytes from a null-terminated platform
/// string.
@@ -234,6 +236,7 @@ extension FilePath.Root: CustomStringConvertible, CustomDebugStringConvertible {
// MARK: - Convenience helpers
// Convenience helpers
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Creates a string by interpreting the path’s content as UTF-8 on Unix
/// and UTF-16 on Windows.
@@ -244,6 +247,7 @@ extension FilePath {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Component {
/// Creates a string by interpreting the component’s content as UTF-8 on Unix
/// and UTF-16 on Windows.
@@ -254,6 +258,7 @@ extension FilePath.Component {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Root {
/// On Unix, this returns `"/"`.
///
@@ -380,6 +385,7 @@ extension String {
// MARK: - Deprecations
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
extension String {
@available(*, deprecated, renamed: "init(decoding:)")
public init(_ path: FilePath) { self.init(decoding: path) }
@@ -388,6 +394,7 @@ extension String {
public init?(validatingUTF8 path: FilePath) { self.init(validating: path) }
}
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
extension FilePath {
@available(*, deprecated, renamed: "init(platformString:)")
public init(cString: UnsafePointer<CChar>) {
+8 -1
View File
@@ -9,7 +9,7 @@
// MARK: - Query API
// @available(...)
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Returns true if this path uniquely identifies the location of
/// a file without reference to an additional starting location.
@@ -103,6 +103,7 @@ extension FilePath {
}
// MARK: - Decompose a path
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Returns the root of a path if there is one, otherwise `nil`.
///
@@ -187,6 +188,7 @@ extension FilePath {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Returns the final component of the path.
/// Returns `nil` if the path is empty or only contains a root.
@@ -258,6 +260,7 @@ extension FilePath {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath.Component {
/// The extension of this file or directory component.
///
@@ -290,6 +293,7 @@ extension FilePath.Component {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// The extension of the file or directory last component.
@@ -356,6 +360,7 @@ extension FilePath {
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Whether the path is in lexical-normal form, that is `.` and `..`
/// components have been collapsed lexically (i.e. without following
@@ -436,6 +441,7 @@ extension FilePath {
}
// Modification and concatenation API
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// If `prefix` is a prefix of `self`, removes it and returns `true`.
/// Otherwise returns `false`.
@@ -605,6 +611,7 @@ extension FilePath {
}
// MARK - Renamed
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
@available(*, unavailable, renamed: "removingLastComponent()")
public var dirname: FilePath { removingLastComponent() }
+1
View File
@@ -17,6 +17,7 @@
public typealias CModeT = CInterop.Mode
/// A namespace for C and platform types
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public enum CInterop {
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
/// The C `mode_t` type.
@@ -7,6 +7,7 @@
See https://swift.org/LICENSE.txt for license information
*/
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension CInterop {
#if os(Windows)
/// The platform's preferred character type. On Unix, this is an 8-bit C
@@ -54,6 +55,7 @@ extension CInterop.PlatformUnicodeEncoding.CodeUnit {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension String {
/// Creates a string by interpreting the null-terminated platform string as
/// UTF-8 on Unix and UTF-16 on Windows.
@@ -15,7 +15,7 @@ import XCTest
@testable import System
#endif
// @available(9999....)
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
struct TestPathComponents: TestCase {
var path: FilePath
var expectedRoot: FilePath.Root?
@@ -100,9 +100,7 @@ struct TestPathComponents: TestCase {
}
}
// TODO: Note that double-reversal will drop root if FilePath is constructed in between ...
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
final class FilePathComponentsTest: XCTestCase {
func testAdHocRRC() {
var path: FilePath = "/usr/local/bin"
@@ -6,6 +6,7 @@
#endif
// Why can't I write this extension on `FilePath.ComponentView.SubSequence`?
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension Slice where Base == FilePath.ComponentView {
internal var _storageSlice: SystemString.SubSequence {
base._path._storage[self.startIndex._storage ..< self.endIndex._storage]
@@ -14,6 +15,7 @@ extension Slice where Base == FilePath.ComponentView {
// Proposed API that didn't make the cut, but we stil want to keep our testing for
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension FilePath {
/// Returns `self` relative to `base`.
/// This does not cosult the file system or resolve symlinks.
@@ -68,6 +68,7 @@ extension ParsingTestCase {
@testable import System
#endif
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
final class FilePathParsingTest: XCTestCase {
func testNormalization() {
let unixPaths: Array<ParsingTestCase> = [
@@ -146,6 +146,7 @@ extension SyntaxTestCase {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension SyntaxTestCase {
func testComponents(_ path: FilePath, expected: [String]) {
let expectedComponents = expected.map { FilePath.Component($0)! }
@@ -341,6 +342,7 @@ private struct WindowsRootTestCase: TestCase {
var line: UInt
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension WindowsRootTestCase {
func runAllTests() {
withWindowsPaths(enabled: true) {
@@ -355,6 +357,7 @@ extension WindowsRootTestCase {
}
}
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
final class FilePathSyntaxTest: XCTestCase {
func testPathSyntax() {
let unixPaths: Array<SyntaxTestCase> = [
@@ -27,7 +27,7 @@ func filePathFromUnterminatedBytes<S: Sequence>(_ bytes: S) -> FilePath where S.
}
let invalidBytes: [UInt8] = [0x2F, 0x61, 0x2F, 0x62, 0x2F, 0x83]
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
final class FilePathTest: XCTestCase {
struct TestPath {
let filePath: FilePath
+1 -1
View File
@@ -17,7 +17,7 @@ import System
@testable import SystemInternals
// @available...
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
final class MockingTest: XCTestCase {
func testMocking() {
XCTAssertFalse(mockingEnabled)