Skip to content

Commit b30614e

Browse files
Make it Swift 5.8 compatible by trivial syntactic changes (#94)
Just removes `if` and `switch` *expressions*
1 parent 3e076d1 commit b30614e

18 files changed

+92
-85
lines changed

Sources/AsyncProcess/ChunkSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct ChunkSequence: AsyncSequence & Sendable {
4949

5050
public mutating func next() async throws -> Element? {
5151
if self.underlyingIterator != nil {
52-
try await self.underlyingIterator!.next()
52+
return try await self.underlyingIterator!.next()
5353
} else {
5454
throw IllegalStreamConsumptionError(
5555
description: """

Sources/AsyncProcess/FileContentStream.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ private final class ReadIntoAsyncChannelHandler: ChannelDuplexHandler {
183183
private var shouldRead: Bool {
184184
switch self.state {
185185
case .idle:
186-
true
186+
return true
187187
case .error:
188-
false
188+
return false
189189
case .sending:
190-
false
190+
return false
191191
}
192192
}
193193

Sources/AsyncProcess/ProcessExecutor+Convenience.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ public struct OutputLoggingSettings: Sendable {
3737
func logMessage(line: String) -> Logger.Message {
3838
switch self.to {
3939
case .logMessage:
40-
"\(line)"
40+
return "\(line)"
4141
case .metadata(logMessage: let message, key: _):
42-
message
42+
return message
4343
}
4444
}
4545

4646
func metadata(stream: ProcessOutputStream, line: String) -> Logger.Metadata {
4747
switch self.to {
4848
case .logMessage:
49-
["stream": "\(stream.description)"]
49+
return ["stream": "\(stream.description)"]
5050
case .metadata(logMessage: _, let key):
51-
[key: "\(line)"]
51+
return [key: "\(line)"]
5252
}
5353
}
5454
}

Sources/AsyncProcess/ProcessExecutor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public struct ProcessOutputStream: Sendable & Hashable & CustomStringConvertible
3434
public var description: String {
3535
switch self.backing {
3636
case .standardOutput:
37-
"stdout"
37+
return "stdout"
3838
case .standardError:
39-
"stderr"
39+
return "stderr"
4040
}
4141
}
4242
}

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,12 @@ extension GeneratorCLI {
198198
if isInvokedAsDefaultSubcommand() {
199199
print("deprecated: Please explicity specify the subcommand to run. For example: $ swift-sdk-generator make-linux-sdk")
200200
}
201-
let linuxDistributionDefaultVersion = switch self.linuxDistributionName {
201+
let linuxDistributionDefaultVersion: String
202+
switch self.linuxDistributionName {
202203
case .rhel:
203-
"ubi9"
204+
linuxDistributionDefaultVersion = "ubi9"
204205
case .ubuntu:
205-
"22.04"
206+
linuxDistributionDefaultVersion = "22.04"
206207
}
207208
let linuxDistributionVersion = self.linuxDistributionVersion ?? linuxDistributionDefaultVersion
208209
let linuxDistribution = try LinuxDistribution(name: linuxDistributionName, version: linuxDistributionVersion)

Sources/GeneratorEngine/Cache/SQLite.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ public final class SQLite {
135135
var pathString: String {
136136
switch self {
137137
case let .path(path):
138-
path.string
138+
return path.string
139139
case .memory:
140-
":memory:"
140+
return ":memory:"
141141
case .temporary:
142-
""
142+
return ""
143143
}
144144
}
145145
}

Sources/GeneratorEngine/FileSystem/FileSystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ enum FileSystemError: Error {
2828
extension Error {
2929
func attach(path: FilePath) -> any Error {
3030
if let error = self as? Errno {
31-
FileSystemError.systemError(path, error)
31+
return FileSystemError.systemError(path, error)
3232
} else {
33-
self
33+
return self
3434
}
3535
}
3636
}

Sources/GeneratorEngine/FileSystem/OpenReadableFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public struct OpenReadableFile {
2525
func read() async throws -> ReadableFileStream {
2626
switch self.fileHandle {
2727
case let .local(fileDescriptor):
28-
ReadableFileStream.local(.init(fileDescriptor: fileDescriptor, readChunkSize: self.readChunkSize))
28+
return ReadableFileStream.local(.init(fileDescriptor: fileDescriptor, readChunkSize: self.readChunkSize))
2929
case let .virtual(array):
30-
ReadableFileStream.virtual(.init(bytes: array))
30+
return ReadableFileStream.virtual(.init(bytes: array))
3131
}
3232
}
3333

Sources/GeneratorEngine/FileSystem/ReadableFileStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ public enum ReadableFileStream: AsyncSequence {
2525
public func next() async throws -> [UInt8]? {
2626
switch self {
2727
case let .local(local):
28-
try await local.next()
28+
return try await local.next()
2929
case let .virtual(virtual):
30-
try await virtual.next()
30+
return try await virtual.next()
3131
}
3232
}
3333
}
3434

3535
public func makeAsyncIterator() -> Iterator {
3636
switch self {
3737
case let .local(local):
38-
.local(local.makeAsyncIterator())
38+
return .local(local.makeAsyncIterator())
3939
case let .virtual(virtual):
40-
.virtual(virtual.makeAsyncIterator())
40+
return .virtual(virtual.makeAsyncIterator())
4141
}
4242
}
4343
}

Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import struct SystemPackage.FilePath
1717
private extension Triple {
1818
var llvmBinaryURLSuffix: String {
1919
switch (self.os, self.arch) {
20-
case (.linux, .aarch64): "aarch64-linux-gnu"
21-
case (.linux, .x86_64): "x86_64-linux-gnu-ubuntu-22.04"
22-
case (.macosx, .aarch64): "arm64-apple-darwin22.0"
23-
case (.macosx, .x86_64): "x86_64-apple-darwin22.0"
20+
case (.linux, .aarch64): return "aarch64-linux-gnu"
21+
case (.linux, .x86_64): return "x86_64-linux-gnu-ubuntu-22.04"
22+
case (.macosx, .aarch64): return "arm64-apple-darwin22.0"
23+
case (.macosx, .x86_64): return "x86_64-apple-darwin22.0"
2424
default: fatalError("\(self) is not supported as LLVM host platform yet")
2525
}
2626
}

0 commit comments

Comments
 (0)