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

Find a way to get Never implementation covered by test coverage #79

Open
dimitribouniol opened this issue Mar 2, 2025 · 0 comments
Open

Comments

@dimitribouniol
Copy link
Member

This implementation currently cannot be called by tests:

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
extension Never: @retroactive Codable {
/// A default implementation for Never for macOS 13, since official support was added in macOS 14.
///
/// - SeeAlso: https://github.com/swiftlang/swift/blob/af3e7e765549c0397288e60983c96d81639287ed/stdlib/public/core/Policy.swift#L81-L86
public func encode(to encoder: any Encoder) throws {}

An attempt was made in dimitri/never-tests:

// struct CustomEncoder: Encoder {
// var codingPath: [any CodingKey] = []
// var userInfo: [CodingUserInfoKey : Any] = [:]
//
// func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key : CodingKey {
// fatalError()
// }
//
// func unkeyedContainer() -> any UnkeyedEncodingContainer {
// fatalError()
// }
//
// func singleValueContainer() -> any SingleValueEncodingContainer {
// fatalError()
// }
// }
//
// struct DummyNever: Encodable {}
//
// let encodeFunction = unsafeBitCast(Never.encode, to: type(of: DummyNever.encode))
// try encodeFunction(DummyNever())(CustomEncoder())

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

No branches or pull requests

1 participant