Skip to content

Commit a9f21aa

Browse files
authored
[6.1] Mark #expect(_:throws:) and #require(_:throws:) as to-be-deprecated. (#879)
- **Explanation**: We should have marked these changes as to-be-deprecated, not hard-deprecated yet. - **Scope**: Swift 6.1, anybody using `#expect(throws:)`. - **Issues**: #873 - **Original PRs**: #875 - **Risk**: Low, this is mostly just documentation changes. - **Testing**: Automated testing. - **Reviewers**: @briancroom
1 parent 39d9c14 commit a9f21aa

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

Diff for: Documentation/Proposals/0006-return-errors-from-expect-throws.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ is not statically available. The problematic overloads will also be deprecated:
105105
-) where E: Error & Equatable
106106
+) -> E where E: Error & Equatable
107107

108-
+@available(*, deprecated, message: "Examine the result of '#expect(throws:)' instead.")
108+
+@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#expect(throws:)' instead.")
109109
+@discardableResult
110110
@freestanding(expression) public macro expect<R>(
111111
_ comment: @autoclosure () -> Comment? = nil,
@@ -115,7 +115,7 @@ is not statically available. The problematic overloads will also be deprecated:
115115
-)
116116
+) -> (any Error)?
117117

118-
+@available(*, deprecated, message: "Examine the result of '#require(throws:)' instead.")
118+
+@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#require(throws:)' instead.")
119119
+@discardableResult
120120
@freestanding(expression) public macro require<R>(
121121
_ comment: @autoclosure () -> Comment? = nil,

Diff for: Sources/Testing/Expectations/Expectation+Macro.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public macro require<R>(
375375
/// ``expect(throws:_:sourceLocation:performing:)-1hfms`` instead. If the thrown
376376
/// error need only equal another instance of [`Error`](https://developer.apple.com/documentation/swift/error),
377377
/// use ``expect(throws:_:sourceLocation:performing:)-7du1h`` instead.
378-
@available(*, deprecated, message: "Examine the result of '#expect(throws:)' instead.")
378+
@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#expect(throws:)' instead.")
379379
@discardableResult
380380
@freestanding(expression) public macro expect<R>(
381381
_ comment: @autoclosure () -> Comment? = nil,
@@ -427,7 +427,7 @@ public macro require<R>(
427427
///
428428
/// If `expression` should _never_ throw, simply invoke the code without using
429429
/// this macro. The test will then fail if an error is thrown.
430-
@available(*, deprecated, message: "Examine the result of '#require(throws:)' instead.")
430+
@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#require(throws:)' instead.")
431431
@discardableResult
432432
@freestanding(expression) public macro require<R>(
433433
_ comment: @autoclosure () -> Comment? = nil,

Diff for: Sources/Testing/Testing.docc/AvailabilityStubs/ExpectComplexThrows.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1111
-->
1212

1313
@Metadata {
14-
@Available(Swift, introduced: 6.0, deprecated: 999.0)
15-
@Available(Xcode, introduced: 16.0, deprecated: 999.0)
14+
@Available(Swift, introduced: 6.0)
15+
@Available(Xcode, introduced: 16.0)
1616
}
1717

18-
@DeprecationSummary {
18+
@DeprecationSummary { <!-- Warning when compiling DocC: rdar://141785948 -->
1919
Examine the result of ``expect(throws:_:sourceLocation:performing:)-7du1h`` or
2020
``expect(throws:_:sourceLocation:performing:)-1hfms`` instead:
2121

Diff for: Sources/Testing/Testing.docc/AvailabilityStubs/RequireComplexThrows.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1111
-->
1212

1313
@Metadata {
14-
@Available(Swift, introduced: 6.0, deprecated: 999.0)
15-
@Available(Xcode, introduced: 16.0, deprecated: 999.0)
14+
@Available(Swift, introduced: 6.0)
15+
@Available(Xcode, introduced: 16.0)
1616
}
1717

18-
@DeprecationSummary {
18+
@DeprecationSummary { <!-- Warning when compiling DocC: rdar://141785948 -->
1919
Examine the result of ``require(throws:_:sourceLocation:performing:)-7n34r``
2020
or ``require(throws:_:sourceLocation:performing:)-4djuw`` instead:
2121

Diff for: Tests/TestingTests/IssueTests.swift

-8
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ final class IssueTests: XCTestCase {
491491
}.run(configuration: .init())
492492
}
493493

494-
@available(*, deprecated)
495494
func testErrorCheckingWithExpect() async throws {
496495
let expectationFailed = expectation(description: "Expectation failed")
497496
expectationFailed.isInverted = true
@@ -540,7 +539,6 @@ final class IssueTests: XCTestCase {
540539
await fulfillment(of: [expectationFailed], timeout: 0.0)
541540
}
542541

543-
@available(*, deprecated)
544542
func testErrorCheckingWithExpect_Mismatching() async throws {
545543
let expectationFailed = expectation(description: "Expectation failed")
546544
expectationFailed.expectedFulfillmentCount = 13
@@ -665,7 +663,6 @@ final class IssueTests: XCTestCase {
665663
await fulfillment(of: [expectationFailed], timeout: 0.0)
666664
}
667665

668-
@available(*, deprecated)
669666
func testErrorCheckingWithExpectAsync() async throws {
670667
let expectationFailed = expectation(description: "Expectation failed")
671668
expectationFailed.isInverted = true
@@ -709,7 +706,6 @@ final class IssueTests: XCTestCase {
709706
await fulfillment(of: [expectationFailed], timeout: 0.0)
710707
}
711708

712-
@available(*, deprecated)
713709
func testErrorCheckingWithExpectAsync_Mismatching() async throws {
714710
let expectationFailed = expectation(description: "Expectation failed")
715711
expectationFailed.expectedFulfillmentCount = 13
@@ -826,7 +822,6 @@ final class IssueTests: XCTestCase {
826822
await fulfillment(of: [expectationFailed], timeout: 0.0)
827823
}
828824

829-
@available(*, deprecated)
830825
func testErrorCheckingWithExpect_ThrowingFromErrorMatcher() async throws {
831826
let errorCaught = expectation(description: "Error matcher's error caught")
832827
let expectationFailed = expectation(description: "Expectation failed")
@@ -854,7 +849,6 @@ final class IssueTests: XCTestCase {
854849
await fulfillment(of: [errorCaught, expectationFailed], timeout: 0.0)
855850
}
856851

857-
@available(*, deprecated)
858852
func testErrorCheckingWithExpectAsync_ThrowingFromErrorMatcher() async throws {
859853
let errorCaught = expectation(description: "Error matcher's error caught")
860854
let expectationFailed = expectation(description: "Expectation failed")
@@ -882,7 +876,6 @@ final class IssueTests: XCTestCase {
882876
await fulfillment(of: [errorCaught, expectationFailed], timeout: 0.0)
883877
}
884878

885-
@available(*, deprecated)
886879
func testErrorCheckingWithRequire_ThrowingFromErrorMatcher() async throws {
887880
let errorCaught = expectation(description: "Error matcher's error caught")
888881
let expectationFailed = expectation(description: "Expectation failed")
@@ -911,7 +904,6 @@ final class IssueTests: XCTestCase {
911904
await fulfillment(of: [errorCaught, expectationFailed], timeout: 0.0)
912905
}
913906

914-
@available(*, deprecated)
915907
func testErrorCheckingWithRequireAsync_ThrowingFromErrorMatcher() async throws {
916908
let errorCaught = expectation(description: "Error matcher's error caught")
917909
let expectationFailed = expectation(description: "Expectation failed")

0 commit comments

Comments
 (0)