You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// An enum where the last case value is "unknown" and can be used as a default catch-all.
public protocol CaseIterableDefaultsLast: Decodable & CaseIterable & RawRepresentable {}
public extension CaseIterableDefaultsLast where RawValue: Decodable, AllCases: BidirectionalCollection {
/// Initializes an enum such that if a known raw value is found, then it is decoded.
/// Otherwise the last case ("unknown") is used.
/// - Parameter decoder: A decoder.
init(from decoder: Decoder) throws {
if let value = try Self(rawValue: decoder.singleValueContainer().decode(RawValue.self)) {
self = value
} else if let lastValue = Self.allCases.last {
self = lastValue
} else {
throw DecodingError.valueNotFound(
Self.Type.self,
.init(codingPath: decoder.codingPath, debugDescription: "CaseIterableDefaultsLast")
)
}
}
}
But when run the test, the generated files got compiler error: Use of protocol 'CaseIterableDefaultsLast' as a type must be written 'any CaseIterableDefaultsLast' Compiler Error
Example
If the generator produces code that is malformed or does not compile, please provide:
A minimal example of the original source
The actual mocking code generated
@available(*, unavailable, message: "'CaseIterableDefaultsLast' inherits from the externally-defined type 'Decodable & CaseIterable & RawRepresentable' which needs to be declared in a supporting source file")
public func mock(_ type: CaseIterableDefaultsLast.Protocol, file: StaticString = #file, line: UInt = #line) -> CaseIterableDefaultsLastMock {
fatalError()
}
I always getting this error that turns my unit test cannot be tested. Please give me suggestion how to solve this problem? Or maybe need some enhancement from the Mockingbirds?
Expected Behavior
@available(*, unavailable, message: "'CaseIterableDefaultsLast' inherits from the externally-defined type 'Decodable & CaseIterable & RawRepresentable' which needs to be declared in a supporting source file")
public func mock(_ type: any CaseIterableDefaultsLast, file: StaticString = #file, line: UInt = #line) -> CaseIterableDefaultsLastMock {
fatalError()
}
New Issue Checklist
Overview
I created a new protocol:
But when run the test, the generated files got compiler error:
Use of protocol 'CaseIterableDefaultsLast' as a type must be written 'any CaseIterableDefaultsLast' Compiler Error
Example
If the generator produces code that is malformed or does not compile, please provide:
I always getting this error that turns my unit test cannot be tested. Please give me suggestion how to solve this problem? Or maybe need some enhancement from the Mockingbirds?
Expected Behavior
Environment
mockingbird version
)swift --version
)The text was updated successfully, but these errors were encountered: