Skip to content

Commit

Permalink
Keep loose compatibility with Swift 5.8 in AsyncFileSystem (swiftlang…
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
kateinoigakukun authored Aug 29, 2024
1 parent 6100d64 commit 630330a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Sources/_AsyncFileSystem/AsyncFileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ extension Error {
/// - Returns: An ``AsyncFileSystemError`` value augmented by the given file path.
func attach(_ path: FilePath) -> any Error {
if let error = self as? Errno {
AsyncFileSystemError.systemError(path, error)
return AsyncFileSystemError.systemError(path, error)
} else {
self
return self
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/_AsyncFileSystem/OpenReadableFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package struct OpenReadableFile: Sendable {
package func read() async throws -> ReadableFileStream {
switch self.fileHandle {
case let .real(fileDescriptor, ioQueue):
ReadableFileStream.real(
return ReadableFileStream.real(
.init(
fileDescriptor: fileDescriptor,
ioQueue: ioQueue,
Expand All @@ -45,7 +45,7 @@ package struct OpenReadableFile: Sendable {
)

case .mock(let array):
ReadableFileStream.mock(.init(bytes: array, chunkSize: self.chunkSize))
return ReadableFileStream.mock(.init(bytes: array, chunkSize: self.chunkSize))
}
}
}
8 changes: 4 additions & 4 deletions Sources/_AsyncFileSystem/ReadableFileStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ package enum ReadableFileStream: AsyncSequence {
package func next() async throws -> ArraySlice<UInt8>? {
switch self {
case .real(let local):
try await local.next()
return try await local.next()
case .mock(let virtual):
try await virtual.next()
return try await virtual.next()
}
}
}

package func makeAsyncIterator() -> Iterator {
switch self {
case .real(let real):
.real(real.makeAsyncIterator())
return .real(real.makeAsyncIterator())
case .mock(let mock):
.mock(mock.makeAsyncIterator())
return .mock(mock.makeAsyncIterator())
}
}
}
Expand Down

0 comments on commit 630330a

Please sign in to comment.