Skip to content

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

Open
@dimitribouniol

Description

@dimitribouniol

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions