Missing generic wrapper with `inout` argument
tgyhlsb opened this issue · 1 comments
tgyhlsb commented
The code below ends up generating mocks that compile:
// sourcery: AutoMockable
protocol GQLClient {
func fetch<Query: GQLQuery>(
query: Query,
completion: @escaping (Result<Query.Data, GQLError>) -> Void
) -> Cancellable
}
But the code below does not:
// sourcery: AutoMockable
protocol GQLStore {
func updateCache<Query: GQLQuery>(
for query: Query,
body: @escaping (inout Query.Data) throws -> Void
)
}
The issue is the inout Query.Data
which combines inout
and generics Query.Data
.
The MethodType
case for updateCache
is:
case m_updateCache__for_querybody_body(Parameter<GenericAttribute>, Parameter<(inout Query.Data) throws -> Void>)
and the compiler complains that Query
is undefined.
Instead it should generate:
case m_updateCache__for_querybody_body(Parameter<GenericAttribute>, Parameter<GenericAttribute>)
I've tried that change manually and after adding some .wrapAsGeneric()
where needed. Code seem to work fine.
I guess the fix should be doable, but I have no idea where to start.
tgyhlsb commented
That may be the fix:
SwiftyMocky/Templates/TypeWrapper.swift
Line 73 in 8f9a004
let tuples = "([\\(,](inout)*\(generic)\(modifiers)[,\\.\\)])"