Skip to content

Commit 8a6a7d9

Browse files
committed
Address availability and compiler versions
1 parent efd6b6c commit 8a6a7d9

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let availabilityTags: [_Availability] = [
1010
_Availability("FoundationPreview"), // Default FoundationPreview availability,
1111
_Availability("FoundationPredicate"), // Predicate relies on pack parameter runtime support
1212
_Availability("FoundationPredicateRegex"), // Predicate regexes rely on new stdlib APIs
13-
_Availability("FoundationSpan"), // Availability of Span types
13+
_Availability("FoundationSpan", availability: .future), // Availability of Span types
1414
]
1515
let versionNumbers = ["0.1", "0.2", "0.3", "0.4", "6.0.2", "6.1", "6.2"]
1616

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ On all other Swift platforms, `swift-foundation` is available as part of the too
1818
## Building and Testing
1919

2020
> [!NOTE]
21-
> Building swift-foundation requires the in-development Swift 6.0 toolchain. You can download the Swift 6.0 nightly toolchain from [the Swift website](https://swift.org/install).
21+
> Building swift-foundation requires the in-development Swift 6.2 toolchain. You can download the Swift 6.2 nightly toolchain from [the Swift website](https://swift.org/install).
2222
2323
Before building Foundation, first ensure that you have a Swift toolchain installed. Next, check out the _Getting Started_ section of the [Foundation Build Process](Foundation_Build_Process.md#getting-started) guide for detailed steps on building and testing.
2424

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,9 @@ internal final class __DataStorage : @unchecked Sendable {
605605

606606
@frozen
607607
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
608+
#if compiler(>=6.2)
608609
@_addressableForDependencies
610+
#endif
609611
public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollection, RangeReplaceableCollection, MutableDataProtocol, ContiguousBytes, Sendable {
610612

611613
public typealias Index = Int
@@ -2201,7 +2203,6 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
22012203
return try _representation.withUnsafeBytes(body)
22022204
}
22032205

2204-
#if compiler(>=6.2)
22052206
@available(FoundationSpan 6.2, *)
22062207
public var bytes: RawSpan {
22072208
@lifetime(borrow self)
@@ -2297,7 +2298,6 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
22972298
#endif
22982299
}
22992300
}
2300-
#endif
23012301

23022302
@_alwaysEmitIntoClient
23032303
public func withContiguousStorageIfAvailable<ResultType>(_ body: (_ buffer: UnsafeBufferPointer<UInt8>) throws -> ResultType) rethrows -> ResultType? {
@@ -2971,7 +2971,6 @@ extension Data : Codable {
29712971
}
29722972
}
29732973

2974-
#if compiler(>=6.2)
29752974
// TODO: remove once _overrideLifetime is public in the standard library
29762975

29772976
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
@@ -3028,4 +3027,3 @@ internal func _overrideLifetime<
30283027
// should be expressed by a builtin that is hidden within the function body.
30293028
dependent
30303029
}
3031-
#endif

Tests/FoundationEssentialsTests/DataTests.swift

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,8 +1634,9 @@ class DataTests : XCTestCase {
16341634
// source.advanced(by: 5)
16351635
}
16361636

1637-
@available(FoundationSpan 6.2, *)
16381637
func test_InlineDataSpan() throws {
1638+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1639+
16391640
var source = Data()
16401641
var span = source.span
16411642
XCTAssertTrue(span.isEmpty)
@@ -1647,16 +1648,18 @@ class DataTests : XCTestCase {
16471648
XCTAssertEqual(span[0], 1)
16481649
}
16491650

1650-
@available(FoundationSpan 6.2, *)
16511651
func test_InlineSliceDataSpan() throws {
1652+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1653+
16521654
let source = Data(0 ... .max)
16531655
let span = source.span
16541656
XCTAssertEqual(span.count, source.count)
16551657
XCTAssertEqual(span[span.indices.last!], .max)
16561658
}
16571659

1658-
@available(FoundationSpan 6.2, *)
16591660
func test_LargeSliceDataSpan() throws {
1661+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1662+
16601663
#if _pointerBitWidth(_64)
16611664
let count = Int(Int32.max)
16621665
#elseif _pointerBitWidth(_32)
@@ -1671,8 +1674,9 @@ class DataTests : XCTestCase {
16711674
XCTAssertFalse(span.isEmpty)
16721675
}
16731676

1674-
@available(FoundationSpan 6.2, *)
16751677
func test_InlineDataMutableSpan() throws {
1678+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1679+
16761680
var source = Data()
16771681
var span = source.mutableSpan
16781682
XCTAssertTrue(span.isEmpty)
@@ -1688,8 +1692,9 @@ class DataTests : XCTestCase {
16881692
XCTAssertEqual(source[i], v)
16891693
}
16901694

1691-
@available(FoundationSpan 6.2, *)
16921695
func test_InlineSliceDataMutableSpan() throws {
1696+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1697+
16931698
var source = Data(0..<100)
16941699
let count = source.count
16951700
var span = source.mutableSpan
@@ -1699,15 +1704,16 @@ class DataTests : XCTestCase {
16991704
XCTAssertEqual(source[i], .max)
17001705
}
17011706

1702-
@available(FoundationSpan 6.2, *)
17031707
func test_LargeSliceDataMutableSpan() throws {
1704-
#if _pointerBitWidth(_64)
1708+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1709+
1710+
#if _pointerBitWidth(_64)
17051711
var count = Int(Int32.max)
1706-
#elseif _pointerBitWidth(_32)
1712+
#elseif _pointerBitWidth(_32)
17071713
var count = Int(Int16.max)
1708-
#else
1714+
#else
17091715
#error("This test needs updating")
1710-
#endif
1716+
#endif
17111717

17121718
var source = Data(repeating: 0, count: count).dropFirst()
17131719
XCTAssertNotEqual(source.startIndex, 0)
@@ -1720,8 +1726,9 @@ class DataTests : XCTestCase {
17201726
XCTAssertEqual(source[i+1], .max)
17211727
}
17221728

1723-
@available(FoundationSpan 6.2, *)
17241729
func test_InlineDataMutableRawSpan() throws {
1730+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1731+
17251732
var source = Data()
17261733
var span = source.mutableBytes
17271734
XCTAssertTrue(span.isEmpty)
@@ -1737,8 +1744,9 @@ class DataTests : XCTestCase {
17371744
XCTAssertEqual(source[i], v)
17381745
}
17391746

1740-
@available(FoundationSpan 6.2, *)
17411747
func test_InlineSliceDataMutableRawSpan() throws {
1748+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1749+
17421750
var source = Data(0..<100)
17431751
let count = source.count
17441752
var span = source.mutableBytes
@@ -1748,8 +1756,9 @@ class DataTests : XCTestCase {
17481756
XCTAssertEqual(source[i], .max)
17491757
}
17501758

1751-
@available(FoundationSpan 6.2, *)
17521759
func test_LargeSliceDataMutableRawSpan() throws {
1760+
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
1761+
17531762
#if _pointerBitWidth(_64)
17541763
var count = Int(Int32.max)
17551764
#elseif _pointerBitWidth(_32)

0 commit comments

Comments
 (0)