Because XCTFail() isn't annotated @noreturn, it isn't sufficient in a guard statement
guard var b = a as? B else {
XCTFail("Result wasn't castable to B")
return //this is redundant
}
This could be broken down into a XCTAssertTrue(a is B) statement, followed by a forced cast, but that seems redundant.
I realize that continueAfterFailure exists to make the test cases continue even after failures. This complicates the solution beyond just adding the @noreturn annotation.
The only solution I can think of happens to be the simplest: add a new variation of XCTFail() that ignores continueAfterFailure, such as XCTAlwaysFail()
A true solution would be for the @noreturn attribute to be conditional… the compiler would somehow need to be aware of the continueAfterFailure property's value. I don't know how that could be done.
Thoughts?
- Regards,
Alexander Momchilov