From 630330a62d7bc0ea115e612d69ad2ba2a65e6fbe Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 29 Aug 2024 10:56:01 +0900 Subject: [PATCH] Keep loose compatibility with Swift 5.8 in AsyncFileSystem (#7928) AsyncFileSystem is going to be vendored into swift-sdk-generator (https://github.com/swiftlang/swift-sdk-generator/pull/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. --- Sources/_AsyncFileSystem/AsyncFileSystem.swift | 4 ++-- Sources/_AsyncFileSystem/OpenReadableFile.swift | 4 ++-- Sources/_AsyncFileSystem/ReadableFileStream.swift | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/_AsyncFileSystem/AsyncFileSystem.swift b/Sources/_AsyncFileSystem/AsyncFileSystem.swift index 47ec012063c..8bee554e2e1 100644 --- a/Sources/_AsyncFileSystem/AsyncFileSystem.swift +++ b/Sources/_AsyncFileSystem/AsyncFileSystem.swift @@ -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 } } } diff --git a/Sources/_AsyncFileSystem/OpenReadableFile.swift b/Sources/_AsyncFileSystem/OpenReadableFile.swift index fa9b77622c5..11cb298c80c 100644 --- a/Sources/_AsyncFileSystem/OpenReadableFile.swift +++ b/Sources/_AsyncFileSystem/OpenReadableFile.swift @@ -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, @@ -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)) } } } diff --git a/Sources/_AsyncFileSystem/ReadableFileStream.swift b/Sources/_AsyncFileSystem/ReadableFileStream.swift index 205796057e3..49635133f19 100644 --- a/Sources/_AsyncFileSystem/ReadableFileStream.swift +++ b/Sources/_AsyncFileSystem/ReadableFileStream.swift @@ -28,9 +28,9 @@ package enum ReadableFileStream: AsyncSequence { package func next() async throws -> ArraySlice? { 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() } } } @@ -38,9 +38,9 @@ package enum ReadableFileStream: AsyncSequence { 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()) } } }