Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCTUnwrap should be added to default --autoclosures list #1975

Open
nicklockwood opened this issue Feb 10, 2025 · 0 comments
Open

XCTUnwrap should be added to default --autoclosures list #1975

nicklockwood opened this issue Feb 10, 2025 · 0 comments
Labels

Comments

@nicklockwood
Copy link
Owner

This can also happen with just try and no await -- SwiftFormat removes the second try from this:

/// Try to cast the object to the given type, and throw if it fails (`as?` + `XCTUnwrap`).
func XCTCast<TSource, TTarget>(
    _ expression: @autoclosure () throws -> TSource,
    _: TTarget.Type = TTarget.self,
    _ message: String = "",
    file: StaticString = #file,
    line: UInt = #line
) throws -> TTarget {
    try XCTUnwrap(try expression() as? TTarget, message, file: file, line: line)
}

Originally posted by @bbrk24 in #1478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant