From e896b567b34bdf4e2e07bf99bf8edff709e1e2d7 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 1 Jul 2025 14:11:31 -0700 Subject: [PATCH 1/7] Remove re-definitions of `_overrideLifetime()` - These have now propagated to become public in all the relevant sources of the stdlib. --- Sources/FoundationEssentials/Data/Data.swift | 50 -------------------- 1 file changed, 50 deletions(-) diff --git a/Sources/FoundationEssentials/Data/Data.swift b/Sources/FoundationEssentials/Data/Data.swift index b6b73ed46..a45798dc3 100644 --- a/Sources/FoundationEssentials/Data/Data.swift +++ b/Sources/FoundationEssentials/Data/Data.swift @@ -2970,53 +2970,3 @@ extension Data : Codable { } } } - -// TODO: remove once _overrideLifetime is public in the standard library -/// Unsafely discard any lifetime dependency on the `dependent` argument. Return -/// a value identical to `dependent` with a lifetime dependency on the caller's -/// borrow scope of the `source` argument. -@unsafe -@_unsafeNonescapableResult -@_alwaysEmitIntoClient -@_transparent -@lifetime(borrow source) -internal func _overrideLifetime< - T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable ->( - _ dependent: consuming T, borrowing source: borrowing U -) -> T { - dependent -} - -/// Unsafely discard any lifetime dependency on the `dependent` argument. Return -/// a value identical to `dependent` that inherits all lifetime dependencies from -/// the `source` argument. -@unsafe -@_unsafeNonescapableResult -@_alwaysEmitIntoClient -@_transparent -@lifetime(copy source) -internal func _overrideLifetime< - T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable ->( - _ dependent: consuming T, copying source: borrowing U -) -> T { - dependent -} - -/// Unsafely discard any lifetime dependency on the `dependent` argument. -/// Return a value identical to `dependent` with a lifetime dependency -/// on the caller's exclusive borrow scope of the `source` argument. -@unsafe -@_unsafeNonescapableResult -@_alwaysEmitIntoClient -@_transparent -@lifetime(&source) -internal func _overrideLifetime< - T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable ->( - _ dependent: consuming T, - mutating source: inout U -) -> T { - dependent -} From c88023396c7c7ba8a64d851e5f1c43f903c0351e Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 1 Jul 2025 16:29:23 -0700 Subject: [PATCH 2/7] Update availability of `Span` projections --- Sources/FoundationEssentials/Data/Data.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/FoundationEssentials/Data/Data.swift b/Sources/FoundationEssentials/Data/Data.swift index a45798dc3..ecea12041 100644 --- a/Sources/FoundationEssentials/Data/Data.swift +++ b/Sources/FoundationEssentials/Data/Data.swift @@ -2203,7 +2203,8 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect return try _representation.withUnsafeBytes(body) } - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @_alwaysEmitIntoClient public var bytes: RawSpan { @lifetime(borrow self) borrowing get { @@ -2230,7 +2231,8 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @_alwaysEmitIntoClient public var span: Span { @lifetime(borrow self) borrowing get { @@ -2239,7 +2241,8 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @_alwaysEmitIntoClient public var mutableBytes: MutableRawSpan { @lifetime(&self) mutating get { @@ -2266,7 +2269,8 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @_alwaysEmitIntoClient public var mutableSpan: MutableSpan { @lifetime(&self) mutating get { From c05b36834369e6fe770ecd6db7151a962610271a Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 1 Jul 2025 16:29:51 -0700 Subject: [PATCH 3/7] Adjust availability of `Span` tests --- .../FoundationEssentialsTests/DataTests.swift | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Tests/FoundationEssentialsTests/DataTests.swift b/Tests/FoundationEssentialsTests/DataTests.swift index a2333f567..7e6550c06 100644 --- a/Tests/FoundationEssentialsTests/DataTests.swift +++ b/Tests/FoundationEssentialsTests/DataTests.swift @@ -1645,8 +1645,9 @@ private final class DataTests { #endif } - @available(FoundationSpan 6.2, *) - @Test func inlineDataSpan() throws { + @Test + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + func inlineDataSpan() throws { var source = Data() var span = source.span var isEmpty = span.isEmpty @@ -1661,16 +1662,18 @@ private final class DataTests { #expect(firstElement == 1) } - @available(FoundationSpan 6.2, *) - @Test func inlineSliceDataSpan() throws { + @Test + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + func inlineSliceDataSpan() throws { let source = Data(0 ... .max) let span = source.span #expect(span.count == source.count) #expect(span[span.indices.last!] == .max) } - @available(FoundationSpan 6.2, *) - @Test func inlineDataMutableSpan() throws { + @Test + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + func inlineDataMutableSpan() throws { #if !canImport(Darwin) || FOUNDATION_FRAMEWORK var source = Data() var span = source.mutableSpan @@ -1693,8 +1696,9 @@ private final class DataTests { #endif } - @available(FoundationSpan 6.2, *) - @Test func inlineSliceDataMutableSpan() throws { + @Test + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + func inlineSliceDataMutableSpan() throws { #if !canImport(Darwin) || FOUNDATION_FRAMEWORK var source = Data(0..<100) let count = source.count @@ -1707,8 +1711,9 @@ private final class DataTests { #endif } - @available(FoundationSpan 6.2, *) - @Test func inlineDataMutableRawSpan() throws { + @Test + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + func inlineDataMutableRawSpan() throws { var source = Data() var span = source.mutableBytes var isEmpty = span.isEmpty @@ -1728,8 +1733,9 @@ private final class DataTests { #expect(source[i] == v) } - @available(FoundationSpan 6.2, *) - @Test func inlineSliceDataMutableRawSpan() throws { + @Test + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + func inlineSliceDataMutableRawSpan() throws { var source = Data(0..<100) let count = source.count var span = source.mutableBytes @@ -2386,7 +2392,7 @@ extension DataTests { @Suite("Large Data Tests", .serialized) struct LargeDataTests { @Test - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func largeSliceDataSpan() throws { #if _pointerBitWidth(_64) let count = Int(Int32.max) @@ -2404,7 +2410,7 @@ struct LargeDataTests { } @Test - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func largeSliceDataMutableSpan() throws { #if _pointerBitWidth(_64) var count = Int(Int32.max) @@ -2428,7 +2434,7 @@ struct LargeDataTests { } @Test - @available(FoundationSpan 6.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func largeSliceDataMutableRawSpan() throws { #if _pointerBitWidth(_64) var count = Int(Int32.max) From 8f607dcfdde4b313bf106e2e03b7767d1d0236b8 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 1 Jul 2025 16:44:31 -0700 Subject: [PATCH 4/7] Make adjustments to mitigate the ABI break --- Sources/FoundationEssentials/Data/Data.swift | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sources/FoundationEssentials/Data/Data.swift b/Sources/FoundationEssentials/Data/Data.swift index ecea12041..648d4cc8f 100644 --- a/Sources/FoundationEssentials/Data/Data.swift +++ b/Sources/FoundationEssentials/Data/Data.swift @@ -2203,6 +2203,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect return try _representation.withUnsafeBytes(body) } + @abi(var _aeic_bytes: RawSpan) @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) @_alwaysEmitIntoClient public var bytes: RawSpan { @@ -2231,6 +2232,12 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } + @abi(var bytes: RawSpan) + @available(*, unavailable) + @usableFromInline + internal var _abi_compatibility_bytes: RawSpan { bytes } + + @abi(var _aeic_span: Span) @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) @_alwaysEmitIntoClient public var span: Span { @@ -2241,6 +2248,12 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } + @abi(var span: Span) + @available(*, unavailable) + @usableFromInline + internal var _abi_compatibility_span: Span { span } + + @abi(var _aeic_mutableBytes: MutableRawSpan) @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) @_alwaysEmitIntoClient public var mutableBytes: MutableRawSpan { @@ -2269,6 +2282,12 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } + @abi(var mutableBytes: MutableRawSpan) + @available(*, unavailable) + @usableFromInline + internal var _abi_compatibility_mutableBytes: MutableRawSpan { mutating get { mutableBytes } } + + @abi(var _aeic_mutableSpan: MutableSpan) @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) @_alwaysEmitIntoClient public var mutableSpan: MutableSpan { @@ -2303,6 +2322,11 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } + @abi(var mutableSpan: MutableSpan) + @available(*, unavailable) + @usableFromInline + internal var _abi_compatibility_mutableSpan: MutableSpan { mutating get { mutableSpan } } + @_alwaysEmitIntoClient public func withContiguousStorageIfAvailable(_ body: (_ buffer: UnsafeBufferPointer) throws -> ResultType) rethrows -> ResultType? { return try _representation.withUnsafeBytes { From 552839568829c70ec49a8ddd4dc7fc0d6468d782 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Wed, 2 Jul 2025 12:52:04 -0700 Subject: [PATCH 5/7] =?UTF-8?q?Remove=20the=20=E2=80=9CFoundationSpan?= =?UTF-8?q?=E2=80=9D=20availability=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 7 ++----- Package.swift | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffb0ea1ab..6e1f9ffba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,6 @@ list(APPEND CMAKE_MODULE_PATH ${SwiftFoundation_SOURCE_DIR}/cmake/modules) # Availability Macros (only applies to FoundationEssentials and FoundationInternationalization) set(_SwiftFoundation_BaseAvailability "macOS 15, iOS 18, tvOS 18, watchOS 11") -set(_SwiftFoundation_macOS26Availability "macOS 26, iOS 26, tvOS 26, watchOS 26") set(_SwiftFoundation_FutureAvailability "macOS 10000, iOS 10000, tvOS 10000, watchOS 10000") # All versions to define for each availability name @@ -106,13 +105,11 @@ list(APPEND _SwiftFoundation_versions # Each availability name to define list(APPEND _SwiftFoundation_availability_names - "FoundationPreview" - "FoundationSpan") + "FoundationPreview") # The aligned availability for each name (in the same order) list(APPEND _SwiftFoundation_availability_releases - ${_SwiftFoundation_BaseAvailability} - ${_SwiftFoundation_macOS26Availability}) + ${_SwiftFoundation_BaseAvailability}) foreach(version ${_SwiftFoundation_versions}) foreach(name release IN ZIP_LISTS _SwiftFoundation_availability_names _SwiftFoundation_availability_releases) diff --git a/Package.swift b/Package.swift index 560a10cf9..371dc21b8 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,6 @@ import CompilerPluginSupport let availabilityTags: [_Availability] = [ _Availability("FoundationPreview"), // Default FoundationPreview availability - _Availability("FoundationSpan", availability: .macOS26), // Availability of Span types ] let versionNumbers = ["6.0.2", "6.1", "6.2"] From aa76444ba1717341657a1ec4e0a14e7c5add8793 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Wed, 2 Jul 2025 13:11:38 -0700 Subject: [PATCH 6/7] Remove availabilities older than the test deployment target --- Tests/FoundationEssentialsTests/DataTests.swift | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Tests/FoundationEssentialsTests/DataTests.swift b/Tests/FoundationEssentialsTests/DataTests.swift index 7e6550c06..64648c118 100644 --- a/Tests/FoundationEssentialsTests/DataTests.swift +++ b/Tests/FoundationEssentialsTests/DataTests.swift @@ -1646,7 +1646,6 @@ private final class DataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func inlineDataSpan() throws { var source = Data() var span = source.span @@ -1663,7 +1662,6 @@ private final class DataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func inlineSliceDataSpan() throws { let source = Data(0 ... .max) let span = source.span @@ -1672,7 +1670,6 @@ private final class DataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func inlineDataMutableSpan() throws { #if !canImport(Darwin) || FOUNDATION_FRAMEWORK var source = Data() @@ -1697,7 +1694,6 @@ private final class DataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func inlineSliceDataMutableSpan() throws { #if !canImport(Darwin) || FOUNDATION_FRAMEWORK var source = Data(0..<100) @@ -1712,7 +1708,6 @@ private final class DataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func inlineDataMutableRawSpan() throws { var source = Data() var span = source.mutableBytes @@ -1734,7 +1729,6 @@ private final class DataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func inlineSliceDataMutableRawSpan() throws { var source = Data(0..<100) let count = source.count @@ -2392,7 +2386,6 @@ extension DataTests { @Suite("Large Data Tests", .serialized) struct LargeDataTests { @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func largeSliceDataSpan() throws { #if _pointerBitWidth(_64) let count = Int(Int32.max) @@ -2410,7 +2403,6 @@ struct LargeDataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func largeSliceDataMutableSpan() throws { #if _pointerBitWidth(_64) var count = Int(Int32.max) @@ -2434,7 +2426,6 @@ struct LargeDataTests { } @Test - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) func largeSliceDataMutableRawSpan() throws { #if _pointerBitWidth(_64) var count = Int(Int32.max) From 6ab2125114a3bb295a55392a46d7f299d05467c2 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Wed, 9 Jul 2025 12:50:58 -0700 Subject: [PATCH 7/7] Availability and symbol adjustments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - abandon abi compatibility attempts, since it doesn’t work - adjust visionOS availability --- Sources/FoundationEssentials/Data/Data.swift | 32 +++----------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/Sources/FoundationEssentials/Data/Data.swift b/Sources/FoundationEssentials/Data/Data.swift index 648d4cc8f..1f684186e 100644 --- a/Sources/FoundationEssentials/Data/Data.swift +++ b/Sources/FoundationEssentials/Data/Data.swift @@ -2203,8 +2203,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect return try _representation.withUnsafeBytes(body) } - @abi(var _aeic_bytes: RawSpan) - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, visionOS 1.1, *) @_alwaysEmitIntoClient public var bytes: RawSpan { @lifetime(borrow self) @@ -2232,13 +2231,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @abi(var bytes: RawSpan) - @available(*, unavailable) - @usableFromInline - internal var _abi_compatibility_bytes: RawSpan { bytes } - - @abi(var _aeic_span: Span) - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, visionOS 1.1, *) @_alwaysEmitIntoClient public var span: Span { @lifetime(borrow self) @@ -2248,13 +2241,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @abi(var span: Span) - @available(*, unavailable) - @usableFromInline - internal var _abi_compatibility_span: Span { span } - - @abi(var _aeic_mutableBytes: MutableRawSpan) - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, visionOS 1.1, *) @_alwaysEmitIntoClient public var mutableBytes: MutableRawSpan { @lifetime(&self) @@ -2282,13 +2269,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @abi(var mutableBytes: MutableRawSpan) - @available(*, unavailable) - @usableFromInline - internal var _abi_compatibility_mutableBytes: MutableRawSpan { mutating get { mutableBytes } } - - @abi(var _aeic_mutableSpan: MutableSpan) - @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *) + @available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, visionOS 1.1, *) @_alwaysEmitIntoClient public var mutableSpan: MutableSpan { @lifetime(&self) @@ -2322,11 +2303,6 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect } } - @abi(var mutableSpan: MutableSpan) - @available(*, unavailable) - @usableFromInline - internal var _abi_compatibility_mutableSpan: MutableSpan { mutating get { mutableSpan } } - @_alwaysEmitIntoClient public func withContiguousStorageIfAvailable(_ body: (_ buffer: UnsafeBufferPointer) throws -> ResultType) rethrows -> ResultType? { return try _representation.withUnsafeBytes {