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

Cannot convert value of type 'String' to expected argument type 'StaticString' (Swift 2) #13

Open
ryanmasondavies opened this issue May 4, 2016 · 1 comment

Comments

@ryanmasondavies
Copy link

This fails to build with Swift 2.2.1.

The errors are as follows:

/Users/Ryan/Downloads/Assertions-master/Assertions/Assertions.swift:87:25: Cannot convert value of type 'String' to expected argument type 'StaticString'
/Users/Ryan/Downloads/Assertions-master/Assertions/Assertions.swift:95:25: Cannot convert value of type 'String' to expected argument type 'StaticString'

The relevant code is:

// MARK: - Failure

/// Logs a failed assertion.
///
/// Returns nil, for use in `x ?? failure(…)` expressions.
public func failure<T>(message: String, file: String = __FILE__, line: UInt = __LINE__) -> T? {
    XCTFail(message, file: file, line: line)
    return nil
}

/// Logs a failed assertion.
///
/// Returns nil, for use in `x ?? failure(…)` expressions.
public func failure(message: String, file: String = __FILE__, line: UInt = __LINE__) -> Bool {
    XCTFail(message, file: file, line: line)
    return false
}

Looks like String needs conversion to StaticString for passing into XCTFail.

Maybe I'm missing something, but I can't find a clear way to perform that conversion. Any ideas?

@robrix
Copy link
Contributor

robrix commented May 5, 2016

IIRC, StaticStrings are compile-time only. Maybe we should pass message around as StaticString instead.

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

No branches or pull requests

2 participants