Skip to content

Commit 97fa781

Browse files
committed
SWBCore,SWBUtil,Tests: avoid some deprecated Swift methods
Update the calls here to avoid some deprecated signatures. Note that the `String(cString:)` initializer was unnecessary as `name` was already a Swift string and did not need to be converted.
1 parent 06b1368 commit 97fa781

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Sources/SWBCore/LibSwiftDriver/LibSwiftDriver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ public final class LibSwiftDriver {
471471
if let scanOracle = oracle, let scanLib = try driver.getSwiftScanLibPath() {
472472
// Errors instantiating the scanner are potentially recoverable, so suppress them here. Truly fatal errors
473473
// will be diagnosed later.
474-
try? scanOracle.verifyOrCreateScannerInstance(fileSystem: fileSystem, swiftScanLibPath: scanLib)
474+
try? scanOracle.verifyOrCreateScannerInstance(swiftScanLibPath: scanLib)
475475
}
476476
#endif
477477
}

Sources/SWBUtil/POSIX.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum POSIX: Sendable {
3131
if GetLastError() == ERROR_ENVVAR_NOT_FOUND {
3232
return nil
3333
}
34-
throw POSIXError(errno, context: "GetEnvironmentVariableW", String(cString: name))
34+
throw POSIXError(errno, context: "GetEnvironmentVariableW", name)
3535
}
3636
return try withUnsafeTemporaryAllocation(of: WCHAR.self, capacity: Int(dwLength)) {
3737
switch GetEnvironmentVariableW(wName, $0.baseAddress!, DWORD($0.count)) {
@@ -40,7 +40,7 @@ public enum POSIX: Sendable {
4040
case 0 where GetLastError() == ERROR_ENVVAR_NOT_FOUND:
4141
return nil
4242
default:
43-
throw POSIXError(errno, context: "GetEnvironmentVariableW", String(cString: name))
43+
throw POSIXError(errno, context: "GetEnvironmentVariableW", name)
4444
}
4545
}
4646
}

Tests/SWBBuildSystemTests/BuildCommandTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fileprivate struct BuildCommandTests: CoreBasedTests {
203203
try results.checkTask(.matchRuleType("Assemble"), .matchRuleItemBasename("File.m"), .matchRuleItem("normal"), .matchRuleItem(results.runDestinationTargetArchitecture)) { task in
204204
task.checkCommandLineContainsUninterrupted(["-x", "objective-c"])
205205
try task.checkCommandLineContainsUninterrupted(["-S", #require(inputs.first).str, "-o", #require(outputs.first)])
206-
let assembly = try String(contentsOfFile: #require(outputs.first))
206+
let assembly = try String(contentsOfFile: #require(outputs.first), encoding: .utf8)
207207
#expect(assembly.hasPrefix("\t.section\t__TEXT,__text,regular,pure_instructions"))
208208
}
209209
results.checkNoTask()
@@ -215,7 +215,7 @@ fileprivate struct BuildCommandTests: CoreBasedTests {
215215
try results.checkTask(.matchRuleType("Assemble"), .matchRuleItemBasename("File.m"), .matchRuleItem("normal"), .matchRuleItem(results.runDestinationTargetArchitecture)) { task in
216216
task.checkCommandLineContainsUninterrupted(["-x", "objective-c"])
217217
try task.checkCommandLineContainsUninterrupted(["-S", #require(inputs.first).str, "-o", #require(outputs.first)])
218-
let assembly = try String(contentsOfFile: #require(outputs.first))
218+
let assembly = try String(contentsOfFile: #require(outputs.first), encoding: .utf8)
219219
#expect(assembly.hasPrefix("\t.section\t__TEXT,__text,regular,pure_instructions"))
220220
}
221221
results.checkNoTask()

Tests/SwiftBuildTests/ConsoleCommands/CLIConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ fileprivate func swiftRuntimePath() throws -> Path? {
313313
let name = "swiftCore.dll"
314314
return try name.withCString(encodedAs: CInterop.PlatformUnicodeEncoding.self) { wName in
315315
guard let handle = GetModuleHandleW(wName) else {
316-
throw POSIXError(errno, context: "GetModuleHandleW", String(cString: name))
316+
throw POSIXError(errno, context: "GetModuleHandleW", name)
317317
}
318318

319319
var capacity = MAX_PATH

0 commit comments

Comments
 (0)