Skip to content

Commit e76a44f

Browse files
authored
Silence a warning on the latest 6.2-dev toolchain when building a test. (#969)
We are getting a (sort of spurious but also not really) warning when building a test where we have a particularly weird bit of code: ```swift func f() -> Never? { nil } try #require(f()) // ⚠️ warning: will never be executed ``` The code in question _will_ be executed, but will always throw an `ExpectationFailedError`. The compiler's getting a bit confused because the expansion of the macro includes a call to a function that returns `T`, where `T` is the type of the expression being unwrapped. Since `T` is `Never` in this context, the compiler infers that that function does not return. The compiler's inference is correct, but it's unclear what exactly it thinks will never be executed here. In any event, the warning is spurious and does not indicate a problem with the test, so I'm changing the return type of the problematic function from `Never?` to `Int?` to make the compiler happy. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 5b60b0a commit e76a44f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Tests/TestingTests/IssueTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ final class IssueTests: XCTestCase {
144144
static func f(_ x: Int) -> Bool { false }
145145
static func g(label x: Int) -> Bool { false }
146146
static func h(_ x: () -> Void) -> Bool { false }
147-
static func j(_ x: Int) -> Never? { nil }
147+
static func j(_ x: Int) -> Int? { nil }
148148
static func k(_ x: inout Int) -> Bool { false }
149149
static func m(_ x: Bool) -> Bool { false }
150150
static func n(_ x: Int) throws -> Bool { false }

0 commit comments

Comments
 (0)