Skip to content

Commit 630330a

Browse files
Keep loose compatibility with Swift 5.8 in AsyncFileSystem (#7928)
AsyncFileSystem is going to be vendored into swift-sdk-generator (swiftlang/swift-sdk-generator#136), and the tool is built with bootstrapping toolchain that is Swift 5.8 on ci.swift.org. This commit makes the vendored AsyncFileSystem compatible with Swift 5.8 by avoiding the use of SE-0380.
1 parent 6100d64 commit 630330a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Sources/_AsyncFileSystem/AsyncFileSystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ extension Error {
6161
/// - Returns: An ``AsyncFileSystemError`` value augmented by the given file path.
6262
func attach(_ path: FilePath) -> any Error {
6363
if let error = self as? Errno {
64-
AsyncFileSystemError.systemError(path, error)
64+
return AsyncFileSystemError.systemError(path, error)
6565
} else {
66-
self
66+
return self
6767
}
6868
}
6969
}

Sources/_AsyncFileSystem/OpenReadableFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ package struct OpenReadableFile: Sendable {
3636
package func read() async throws -> ReadableFileStream {
3737
switch self.fileHandle {
3838
case let .real(fileDescriptor, ioQueue):
39-
ReadableFileStream.real(
39+
return ReadableFileStream.real(
4040
.init(
4141
fileDescriptor: fileDescriptor,
4242
ioQueue: ioQueue,
@@ -45,7 +45,7 @@ package struct OpenReadableFile: Sendable {
4545
)
4646

4747
case .mock(let array):
48-
ReadableFileStream.mock(.init(bytes: array, chunkSize: self.chunkSize))
48+
return ReadableFileStream.mock(.init(bytes: array, chunkSize: self.chunkSize))
4949
}
5050
}
5151
}

Sources/_AsyncFileSystem/ReadableFileStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ package enum ReadableFileStream: AsyncSequence {
2828
package func next() async throws -> ArraySlice<UInt8>? {
2929
switch self {
3030
case .real(let local):
31-
try await local.next()
31+
return try await local.next()
3232
case .mock(let virtual):
33-
try await virtual.next()
33+
return try await virtual.next()
3434
}
3535
}
3636
}
3737

3838
package func makeAsyncIterator() -> Iterator {
3939
switch self {
4040
case .real(let real):
41-
.real(real.makeAsyncIterator())
41+
return .real(real.makeAsyncIterator())
4242
case .mock(let mock):
43-
.mock(mock.makeAsyncIterator())
43+
return .mock(mock.makeAsyncIterator())
4444
}
4545
}
4646
}

0 commit comments

Comments
 (0)