Skip to content

Revert "FoundationEssentials,FoundationInternationalization: adjust for aliasing" #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ let availabilityMacros: [SwiftSetting] = versionNumbers.flatMap { version in

let featureSettings: [SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency"),
.enableExperimentalFeature("ImportMacroAliases"),
.enableUpcomingFeature("InferSendableFromCaptures"),
.enableUpcomingFeature("MemberImportVisibility")
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ import Darwin
#elseif canImport(Android)
@preconcurrency import Android
import posix_filesystem.dirent
internal import _FoundationCShims
#elseif canImport(Glibc)
@preconcurrency import Glibc
internal import _FoundationCShims
Expand Down
1 change: 0 additions & 1 deletion Sources/FoundationInternationalization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ add_subdirectory(TimeZone)

target_compile_options(FoundationInternationalization PRIVATE
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend AccessLevelOnImport>"
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend ImportMacroAliases>"
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend StrictConcurrency>"
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-upcoming-feature -Xfrontend InferSendableFromCaptures>"
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-upcoming-feature -Xfrontend MemberImportVisibility>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ internal class ICUNumberFormatterBase : @unchecked Sendable {
// MARK: -

class FormatResult {
var result: OpaquePointer?
var result: OpaquePointer

init(formatter: OpaquePointer, value: Int64) throws {
var status = U_ZERO_ERROR
Expand Down Expand Up @@ -188,9 +188,7 @@ internal class ICUNumberFormatterBase : @unchecked Sendable {
var str = value.description
#endif // FOUNDATION_FRAMEWORK
str.withUTF8 {
$0.withMemoryRebound(to: CChar.self) {
unumf_formatDecimal(formatter, $0.baseAddress, Int32($0.count), result, &status)
}
unumf_formatDecimal(formatter, $0.baseAddress, Int32($0.count), result, &status)
}
try status.checkSuccess()
}
Expand All @@ -202,9 +200,7 @@ internal class ICUNumberFormatterBase : @unchecked Sendable {

var value = value
value.withUTF8 {
$0.withMemoryRebound(to: CChar.self) {
unumf_formatDecimal(formatter, $0.baseAddress, Int32($0.count), result, &status)
}
unumf_formatDecimal(formatter, $0.baseAddress, Int32($0.count), result, &status)
}

try status.checkSuccess()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import FoundationEssentials

extension ICU {
final class CaseMap : @unchecked Sendable {
let casemap: OpaquePointer?
let casemap: OpaquePointer

let lock: LockedState<Void>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal import _FoundationICU

extension ICU {
final class FieldPositer {
let positer: OpaquePointer?
let positer: OpaquePointer

internal init() throws {
var status = U_ZERO_ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ internal struct ICUError: Error, CustomDebugStringConvertible {
}

var debugDescription: String {
guard let error = u_errorName(code) else {
return "Unknown ICU error \(code.rawValue)"
}
return String(cString: error)
String(validatingUTF8: u_errorName(code)) ?? "Unknown ICU error \(code.rawValue)"
}

#if canImport(os)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extension ICU.StringConverter {
converter,
dest,
capacity,
src.baseAddress?.assumingMemoryBound(to: CChar.self),
src.baseAddress,
srcLength,
&status
)
Expand All @@ -85,7 +85,7 @@ extension ICU.StringConverter {
}

func encode(string: String, allowLossyConversion lossy: Bool) -> Data? {
return self._converter.withLock { (converter) -> Data? in
return _converter.withLock { (converter) -> Data? in
defer {
ucnv_resetFromUnicode(converter)
}
Expand Down Expand Up @@ -117,7 +117,7 @@ extension ICU.StringConverter {

ucnv_setFromUCallBack(
converter,
{ UCNV_FROM_U_CALLBACK_SUBSTITUTE($0, $1, $2, $3, $4, $5, $6) },
UCNV_FROM_U_CALLBACK_SUBSTITUTE,
nil, // newContext
nil, // oldAction
nil, // oldContext
Expand All @@ -127,7 +127,7 @@ extension ICU.StringConverter {
} else {
ucnv_setFromUCallBack(
converter,
{ UCNV_FROM_U_CALLBACK_STOP($0, $1, $2, $3, $4, $5, $6) },
UCNV_FROM_U_CALLBACK_STOP,
nil, // newContext
nil, // oldAction
nil, // oldContext
Expand All @@ -138,7 +138,7 @@ extension ICU.StringConverter {

let actualLength = ucnv_fromUChars(
converter,
dest.assumingMemoryBound(to: CChar.self),
dest,
CInt(capacity),
uchars.baseAddress,
CInt(srcLength),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,7 @@ extension Locale.Region {
return nil
}

guard let region = uregion_getRegionCode(containingRegion) else {
return nil
}

guard let code = String(validatingUTF8: region) else {
guard let code = String(validatingUTF8: uregion_getRegionCode(containingRegion)) else {
return nil
}

Expand All @@ -240,11 +236,7 @@ extension Locale.Region {
return nil
}

guard let region = uregion_getRegionCode(containingContinent) else {
return nil
}

guard let code = String(validatingUTF8: region) else {
guard let code = String(validatingUTF8: uregion_getRegionCode(containingContinent)) else {
return nil
}

Expand Down Expand Up @@ -453,11 +445,7 @@ extension Locale.Region {
return nil
}

guard let region = uregion_getRegionCode(containing) else {
return nil
}

guard let code = String(validatingCString: region) else {
guard let code = String(validatingCString: uregion_getRegionCode(containing)) else {
return nil
}

Expand Down Expand Up @@ -611,8 +599,8 @@ extension Locale.NumberingSystem {
var status = U_ZERO_ERROR
let numberingSystem = unumsys_open(localeIdentifier, &status)
defer { unumsys_close(numberingSystem) }
if let numberingSystem, status.isSuccess, let name = unumsys_getName(numberingSystem) {
self.init(String(cString: name))
if let numberingSystem, status.isSuccess {
self.init(String(cString: unumsys_getName(numberingSystem)))
} else {
self = .latn
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,7 @@ extension Locale {
var working = Set<String>()
let localeCount = uloc_countAvailable()
for locale in 0..<localeCount {
guard let name = uloc_getAvailable(locale) else { continue }
let localeID = String(cString: name)
let localeID = String(cString: uloc_getAvailable(locale))
working.insert(localeID)
}
return Array(working)
Expand Down