Description
Swift Version
6.0
Package Version
0.1.0
Bug Description
It may be desirable to generate a mock from a protocol with associated types. Sometimes, those associated types may themselves have multiple conformances. For example:
public protocol InMemoryStoreProtocol: Sendable {
associatedtype Key: Hashable & Sendable
associatedtype Value: Sendable
...
}
in this case, we require that both the key and the value be sendable. The key has the additional requirement of being hashable. However, if you add the @Mocked
macro to this protocol, it will generate the following:
public final class InMemoryStoreProtocolMock<Key:, Value: Sendable>: InMemoryCacheProtocol { ... }
You can see that the Key
generic argument is succeeded by a colon, but does not actually list any required conformances (like Value
does with Sendable
)! This only happens when the associated type has multiple conformance requirements.
Steps to Reproduce
- Create a protocol that has an associated type.
- Add multiple conformance requirements on that associated type using
&
syntax. - Expand the macro; you will see the bug.
Code of Conduct
- I agree to follow this project's Code of Conduct