Skip to content

Commit 7d9957d

Browse files
authored
Merge pull request #1371 from swiftlang/automerge/merge-main-2025-06-23_09-02
Merge `main` into `release/6.2`
2 parents 5846901 + 7f8c12a commit 7d9957d

22 files changed

+5914
-5402
lines changed

.github/workflows/pull_request.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
tests:
12-
name: Test
12+
name: Test (SwiftPM)
1313
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1414
with:
1515
linux_swift_versions: '["nightly-main"]'
@@ -18,6 +18,23 @@ jobs:
1818
macos_xcode_versions: '["16.3"]'
1919
macos_versions: '["sequoia"]'
2020

21+
cmake_build:
22+
name: Build (CMake)
23+
runs-on: ubuntu-latest
24+
container: swiftlang/swift:nightly-main-noble
25+
steps:
26+
- name: Checkout Sources
27+
uses: actions/checkout@v1
28+
- name: Install Dependencies
29+
shell: bash
30+
run: apt update && apt install -y cmake ninja-build
31+
- name: Configure Project
32+
shell: bash
33+
run: cmake -G 'Ninja' -B build -S . -DCMAKE_C_COMPILER=clang -DCMAKE_Swift_COMPILER=swiftc -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=YES
34+
- name: Build Project
35+
shell: bash
36+
run: cmake --build build
37+
2138
soundness:
2239
name: Soundness
2340
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ else()
7575
message(STATUS "_SwiftFoundationICU_SourceDIR not provided, checking out local copy of swift-foundation-icu")
7676
FetchContent_Declare(SwiftFoundationICU
7777
GIT_REPOSITORY https://github.com/apple/swift-foundation-icu.git
78-
GIT_TAG 0.0.9)
78+
GIT_TAG main)
7979
endif()
8080

8181
if (_SwiftCollections_SourceDIR)

Package.swift

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,6 @@ let package = Package(
150150
swiftSettings: [
151151
.enableExperimentalFeature("VariadicGenerics"),
152152
.enableExperimentalFeature("LifetimeDependence"),
153-
.enableExperimentalFeature(
154-
"InoutLifetimeDependence",
155-
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
156-
),
157-
.enableExperimentalFeature(
158-
"LifetimeDependenceMutableAccessors",
159-
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
160-
),
161153
.enableExperimentalFeature("AddressableTypes"),
162154
.enableExperimentalFeature("AllowUnsafeAttribute"),
163155
.enableExperimentalFeature("BuiltinModule"),
@@ -176,16 +168,7 @@ let package = Package(
176168
resources: [
177169
.copy("Resources")
178170
],
179-
swiftSettings: [
180-
.enableExperimentalFeature(
181-
"InoutLifetimeDependence",
182-
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
183-
),
184-
.enableExperimentalFeature(
185-
"LifetimeDependenceMutableAccessors",
186-
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
187-
),
188-
] + availabilityMacros + featureSettings + testOnlySwiftSettings
171+
swiftSettings: availabilityMacros + featureSettings + testOnlySwiftSettings
189172
),
190173

191174
// FoundationInternationalization

Proposals/0028-locale-region-category.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Authors: [Tina Liu](https://github.com/itingliu)
55
* Review Manager: [Jeremy Schonfeld](https://github.com/jmschonfeld)
66
* Implementation: [https://github.com/swiftlang/swift-foundation/pull/1253]()
7-
* Status: **Review: Jun 11, 2025...Jun 18, 2025**
8-
* Reviews: [Pitch](https://forums.swift.org/t/pitch-category-support-for-locale-region/79240)
7+
* Status: **Accepted**
8+
* Reviews: [Pitch](https://forums.swift.org/t/pitch-category-support-for-locale-region/79240), [Review](https://forums.swift.org/t/review-sf-0028-locale-region-category/80415)
99

1010
## Introduction
1111

Sources/FoundationEssentials/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ endif()
7474

7575
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android)
7676
target_compile_options(FoundationEssentials PRIVATE
77-
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -Xcc -Xfrontend -D_GNU_SOURCE>"
78-
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend InoutLifetimeDependence>"
79-
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend LifetimeDependenceMutableAccessors>")
77+
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -Xcc -Xfrontend -D_GNU_SOURCE>")
8078
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
8179
endif()
8280

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,11 +2203,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
22032203
return try _representation.withUnsafeBytes(body)
22042204
}
22052205

2206-
#if compiler(>=6.2) && $LifetimeDependence
22072206
@available(FoundationSpan 6.2, *)
2208-
#if FOUNDATION_FRAMEWORK
2209-
@_disfavoredOverload
2210-
#endif // FOUNDATION_FRAMEWORK
22112207
public var bytes: RawSpan {
22122208
@lifetime(borrow self)
22132209
borrowing get {
@@ -2242,9 +2238,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
22422238
return _overrideLifetime(span, borrowing: self)
22432239
}
22442240
}
2245-
#endif
22462241

2247-
#if compiler(>=5.9) && $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
22482242
@available(FoundationSpan 6.2, *)
22492243
public var mutableBytes: MutableRawSpan {
22502244
@lifetime(&self)
@@ -2304,7 +2298,6 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
23042298
#endif
23052299
}
23062300
}
2307-
#endif // $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
23082301

23092302
@_alwaysEmitIntoClient
23102303
public func withContiguousStorageIfAvailable<ResultType>(_ body: (_ buffer: UnsafeBufferPointer<UInt8>) throws -> ResultType) rethrows -> ResultType? {
@@ -2979,7 +2972,6 @@ extension Data : Codable {
29792972
}
29802973

29812974
// TODO: remove once _overrideLifetime is public in the standard library
2982-
#if compiler(>=6.2) && $LifetimeDependence
29832975
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
29842976
/// a value identical to `dependent` with a lifetime dependency on the caller's
29852977
/// borrow scope of the `source` argument.
@@ -3011,9 +3003,7 @@ internal func _overrideLifetime<
30113003
) -> T {
30123004
dependent
30133005
}
3014-
#endif
30153006

3016-
#if compiler(>=5.9) && $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
30173007
/// Unsafely discard any lifetime dependency on the `dependent` argument.
30183008
/// Return a value identical to `dependent` with a lifetime dependency
30193009
/// on the caller's exclusive borrow scope of the `source` argument.
@@ -3030,4 +3020,3 @@ internal func _overrideLifetime<
30303020
) -> T {
30313021
dependent
30323022
}
3033-
#endif // $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors

Sources/FoundationEssentials/String/String+IO.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ dynamic public func _cfMakeStringFromBytes(_ bytes: UnsafeBufferPointer<UInt8>,
2424
// Provide swift-corelibs-foundation with an entry point to convert some bytes into a String
2525
return nil
2626
}
27+
28+
dynamic package func _icuMakeStringFromBytes(_ bytes: UnsafeBufferPointer<UInt8>, encoding: String.Encoding) -> String? {
29+
// Concrete implementation is provided by FoundationInternationalization.
30+
return nil
31+
}
2732
#endif
2833

2934
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
@@ -184,6 +189,17 @@ extension String {
184189
}
185190
}
186191
self = bytes.withContiguousStorageIfAvailable(buildString) ?? Array(bytes).withUnsafeBufferPointer(buildString)
192+
case .japaneseEUC:
193+
// Here we catch encodings that are supported by Foundation Framework
194+
// but are not supported by corelibs-foundation.
195+
// We delegate conversion to ICU.
196+
guard let string = (
197+
bytes.withContiguousStorageIfAvailable({ _icuMakeStringFromBytes($0, encoding: encoding) }) ??
198+
Array(bytes).withUnsafeBufferPointer({ _icuMakeStringFromBytes($0, encoding: encoding) })
199+
) else {
200+
return nil
201+
}
202+
self = string
187203
#endif
188204
default:
189205
#if FOUNDATION_FRAMEWORK

Sources/FoundationEssentials/String/StringProtocol+Essentials.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ dynamic public func _cfStringEncodingConvert(string: String, using encoding: UIn
9191
// Dynamically replaced by swift-corelibs-foundation to implement encodings that we do not have Swift replacements for, yet
9292
return nil
9393
}
94+
95+
dynamic package func _icuStringEncodingConvert(string: String, using encoding: String.Encoding, allowLossyConversion: Bool) -> Data? {
96+
// Concrete implementation is provided by FoundationInternationalization.
97+
return nil
98+
}
9499
#endif
95100

96101
@available(FoundationPreview 0.4, *)
@@ -249,6 +254,11 @@ extension String {
249254
buffer.appendElement(value)
250255
}
251256
}
257+
case .japaneseEUC:
258+
// Here we catch encodings that are supported by Foundation Framework
259+
// but are not supported by corelibs-foundation.
260+
// We delegate conversion to ICU.
261+
return _icuStringEncodingConvert(string: self, using: encoding, allowLossyConversion: allowLossyConversion)
252262
#endif
253263
default:
254264
#if FOUNDATION_FRAMEWORK

0 commit comments

Comments
 (0)