Skip to content

Commit 3c84204

Browse files
authored
Address various warnings across the project (#1321)
1 parent 4d74f7a commit 3c84204

File tree

10 files changed

+21
-11
lines changed

10 files changed

+21
-11
lines changed

Sources/FoundationInternationalization/Locale/Locale_ICU.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,8 @@ internal final class _LocaleICU: _LocaleProtocol, Sendable {
12091209
}
12101210
}
12111211

1212-
// Check prefs
1213-
if let firstWeekdayPref = prefs?.firstWeekday {
1212+
// Check prefs. The value doesn't matter here - we check it again in the `forceFirstWeekday` function, and it is immutable.
1213+
if prefs?.firstWeekday != nil {
12141214
let calendarId = calendarIdentifier
12151215
if let first = forceFirstWeekday(calendarId) {
12161216
state.firstDayOfWeek = first

Sources/FoundationInternationalization/Locale/Locale_ObjC.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ internal class _NSSwiftLocale: _NSLocaleBridge, @unchecked Sendable {
308308
switch locale.temperatureUnit {
309309
case .celsius: return NSLocaleTemperatureUnitCelsius
310310
case .fahrenheit: return NSLocaleTemperatureUnitFahrenheit
311+
#if !FOUNDATION_FRAMEWORK
312+
// On non-framework builds, the enum is non-closed and `package` visibility, so we need a default
311313
default: return NSLocaleTemperatureUnitCelsius
314+
#endif
312315
}
313316
case .decimalSeparator: return self.decimalSeparator
314317
case .groupingSeparator: return self.groupingSeparator

Sources/FoundationInternationalization/TimeZone/TimeZone_ICU.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ internal final class _TimeZoneICU: _TimeZoneProtocol, Sendable {
222222
return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: false, isGeneric: true, isDaylight: false)
223223
case .shortGeneric:
224224
return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: true, isGeneric: true, isDaylight: false)
225+
#if FOUNDATION_FRAMEWORK
226+
// We only need this when building in ObjC mode, when the enum comes from a .h
227+
@unknown default:
228+
// Use standard style
229+
return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: false, isGeneric: false, isDaylight: false)
230+
#endif
225231
}
226232
}
227233
}

Tests/FoundationEssentialsTests/AttributedString/AttributedStringIndexValidityTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ final class AttributedStringIndexValidityTests: XCTestCase {
140140
}
141141

142142
public func testMutationInvalidation() {
143-
func checkInPlace(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) {
143+
func checkInPlace(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) {
144144
var str = AttributedString("Hello World")
145145
let idxA = str.startIndex
146146
let idxB = str.index(afterCharacter: idxA)
@@ -158,7 +158,7 @@ final class AttributedStringIndexValidityTests: XCTestCase {
158158
XCTAssertFalse(RangeSet(idxA ..< idxB).isValid(within: str), "Initial range set was valid in in-place mutated", file: file, line: line)
159159
}
160160

161-
func checkCopy(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) {
161+
func checkCopy(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) {
162162
let str = AttributedString("Hello World")
163163
let idxA = str.startIndex
164164
let idxB = str.index(afterCharacter: idxA)
@@ -185,7 +185,7 @@ final class AttributedStringIndexValidityTests: XCTestCase {
185185
XCTAssertFalse(RangeSet(idxA ..< idxB).isValid(within: copy), "Initial range set was valid in copy", file: file, line: line)
186186
}
187187

188-
func check(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) {
188+
func check(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) {
189189
checkInPlace(mutation, file: file, line: line)
190190
checkCopy(mutation, file: file, line: line)
191191
}

Tests/FoundationEssentialsTests/AttributedString/AttributedStringTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ E {
18821882
func check<T: Equatable>(
18831883
_ a: some Sequence<T>,
18841884
_ b: some Sequence<T>,
1885-
file: StaticString = #file, line: UInt = #line
1885+
file: StaticString = #filePath, line: UInt = #line
18861886
) {
18871887
XCTAssertTrue(
18881888
a.elementsEqual(b),

Tests/FoundationEssentialsTests/DataIOTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class DataIOTests : XCTestCase {
185185

186186
#if FOUNDATION_FRAMEWORK
187187
// String(contentsOf:) is not available outside the framework yet
188+
@available(*, deprecated)
188189
func test_emptyFileString() {
189190
let data = Data()
190191
let url = testURL()

Tests/FoundationEssentialsTests/StringTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ final class StringTests : XCTestCase {
13191319

13201320
}
13211321

1322-
func verifyEncoding(_ encoding: String._Encoding, valid: [String], invalid: [String], file: StaticString = #file, line: UInt = #line) throws {
1322+
func verifyEncoding(_ encoding: String._Encoding, valid: [String], invalid: [String], file: StaticString = #filePath, line: UInt = #line) throws {
13231323
for string in valid {
13241324
let data = try XCTUnwrap(string.data(using: encoding), "Failed to encode \(string.debugDescription)", file: file, line: line)
13251325
XCTAssertNotNil(String(data: data, encoding: encoding), "Failed to decode \(data) (\(string.debugDescription))", file: file, line: line)

Tests/FoundationInternationalizationTests/DateComponentsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ final class DateComponentsTests : XCTestCase {
141141
extension DateComponentsTests {
142142
func date(from string: String, nanoseconds: Int? = nil) -> Date {
143143
let d = try! Date(string, strategy: Date.ParseStrategy(format: "\(year: .extended(minimumLength: 4))-\(month: .twoDigits)-\(day: .twoDigits) \(hour: .twoDigits(clock: .twentyFourHour, hourCycle: .zeroBased)):\(minute: .twoDigits):\(second: .twoDigits) \(timeZone: .iso8601(.short))", locale: Locale(identifier: "en_US"), timeZone: TimeZone.gmt))
144-
if let nanoseconds {
145-
var comps = Calendar(identifier: .gregorian).dateComponents([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .timeZone, .calendar], from: d)
144+
if nanoseconds != nil {
145+
let comps = Calendar(identifier: .gregorian).dateComponents([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .timeZone, .calendar], from: d)
146146
return Calendar(identifier: .gregorian).date(from: comps)!
147147
}
148148
return d

Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ final class DateAttributedFormatStyleTests : XCTestCase {
712712

713713
func test(dateStyle: Date.FormatStyle.DateStyle, timeStyle: Date.FormatStyle.TimeStyle, dateFormatOverride: [Date.FormatStyle.DateStyle: String], expected: [Segment], file: StaticString = #filePath, line: UInt = #line) {
714714
let locale = Locale.localeAsIfCurrent(name: enUS, overrides: .init(dateFormats: dateFormatOverride))
715-
let style = Date.FormatStyle(date: dateStyle, time: timeStyle, locale: locale, calendar: Calendar(identifier: .gregorian), timeZone: TimeZone(identifier: "PST")!, capitalizationContext: .standalone).attributed
715+
let style = Date.FormatStyle(date: dateStyle, time: timeStyle, locale: locale, calendar: Calendar(identifier: .gregorian), timeZone: TimeZone(identifier: "PST")!, capitalizationContext: .standalone).attributedStyle
716716
XCTAssertEqual(style.format(date), expected.attributedString, file: file, line: line)
717717
}
718718

Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ final class NumberFormatStyleTests: XCTestCase {
597597

598598
func testCurrency_Codable() throws {
599599
let gbpInUS = Decimal.FormatStyle.Currency(code: "GBP", locale: enUSLocale)
600-
let encoded = try JSONEncoder().encode(gbpInUS)
600+
let _ = try JSONEncoder().encode(gbpInUS)
601601
// Valid JSON presentation of the format style
602602
let previouslyEncoded = """
603603
{

0 commit comments

Comments
 (0)